typescript 4.5.0-dev.20210927 → 4.5.0-dev.20210928
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/de/diagnosticMessages.generated.json +17 -5
- package/lib/it/diagnosticMessages.generated.json +15 -4
- package/lib/ko/diagnosticMessages.generated.json +15 -4
- package/lib/lib.dom.d.ts +669 -1896
- package/lib/lib.dom.iterable.d.ts +16 -48
- package/lib/lib.webworker.d.ts +183 -520
- package/lib/lib.webworker.iterable.d.ts +10 -30
- package/lib/ru/diagnosticMessages.generated.json +15 -4
- package/lib/tsc.js +204 -102
- package/lib/tsserver.js +677 -290
- package/lib/tsserverlibrary.d.ts +10 -8
- package/lib/tsserverlibrary.js +677 -290
- package/lib/typescript.d.ts +10 -8
- package/lib/typescript.js +677 -290
- package/lib/typescriptServices.d.ts +10 -8
- package/lib/typescriptServices.js +677 -290
- package/lib/typingsInstaller.js +255 -111
- package/lib/zh-tw/diagnosticMessages.generated.json +15 -4
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20210928";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -8187,6 +8187,8 @@ var ts;
|
|
|
8187
8187
|
Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8188
8188
|
Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8189
8189
|
Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8190
|
+
The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
|
|
8191
|
+
The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
|
|
8190
8192
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8191
8193
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
8192
8194
|
Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -12974,7 +12976,7 @@ var ts;
|
|
|
12974
12976
|
switch (node.kind) {
|
|
12975
12977
|
case 269 /* ImportSpecifier */:
|
|
12976
12978
|
case 274 /* ExportSpecifier */:
|
|
12977
|
-
return node.parent.parent.isTypeOnly;
|
|
12979
|
+
return node.isTypeOnly || node.parent.parent.isTypeOnly;
|
|
12978
12980
|
case 267 /* NamespaceImport */:
|
|
12979
12981
|
return node.parent.isTypeOnly;
|
|
12980
12982
|
case 266 /* ImportClause */:
|
|
@@ -19785,7 +19787,8 @@ var ts;
|
|
|
19785
19787
|
var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd));
|
|
19786
19788
|
var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd));
|
|
19787
19789
|
var isDirectory = false;
|
|
19788
|
-
while (
|
|
19790
|
+
while (aParts.length >= 2 && bParts.length >= 2 &&
|
|
19791
|
+
!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
|
|
19789
19792
|
!isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
|
|
19790
19793
|
getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
|
|
19791
19794
|
aParts.pop();
|
|
@@ -19797,7 +19800,7 @@ var ts;
|
|
|
19797
19800
|
// KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink.
|
|
19798
19801
|
// ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked.
|
|
19799
19802
|
function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
|
|
19800
|
-
return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@");
|
|
19803
|
+
return s !== undefined && (getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"));
|
|
19801
19804
|
}
|
|
19802
19805
|
function stripLeadingDirectorySeparator(s) {
|
|
19803
19806
|
return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined;
|
|
@@ -20428,10 +20431,6 @@ var ts;
|
|
|
20428
20431
|
|| !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
|
|
20429
20432
|
}
|
|
20430
20433
|
ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
|
|
20431
|
-
function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
|
|
20432
|
-
return typeOnlyDeclaration.kind === 274 /* ExportSpecifier */;
|
|
20433
|
-
}
|
|
20434
|
-
ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
|
|
20435
20434
|
function isShorthandPropertyNameUseSite(useSite) {
|
|
20436
20435
|
return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite;
|
|
20437
20436
|
}
|
|
@@ -24453,8 +24452,9 @@ var ts;
|
|
|
24453
24452
|
: node;
|
|
24454
24453
|
}
|
|
24455
24454
|
// @api
|
|
24456
|
-
function createImportSpecifier(propertyName, name) {
|
|
24455
|
+
function createImportSpecifier(isTypeOnly, propertyName, name) {
|
|
24457
24456
|
var node = createBaseNode(269 /* ImportSpecifier */);
|
|
24457
|
+
node.isTypeOnly = isTypeOnly;
|
|
24458
24458
|
node.propertyName = propertyName;
|
|
24459
24459
|
node.name = name;
|
|
24460
24460
|
node.transformFlags |=
|
|
@@ -24464,10 +24464,11 @@ var ts;
|
|
|
24464
24464
|
return node;
|
|
24465
24465
|
}
|
|
24466
24466
|
// @api
|
|
24467
|
-
function updateImportSpecifier(node, propertyName, name) {
|
|
24468
|
-
return node.
|
|
24467
|
+
function updateImportSpecifier(node, isTypeOnly, propertyName, name) {
|
|
24468
|
+
return node.isTypeOnly !== isTypeOnly
|
|
24469
|
+
|| node.propertyName !== propertyName
|
|
24469
24470
|
|| node.name !== name
|
|
24470
|
-
? update(createImportSpecifier(propertyName, name), node)
|
|
24471
|
+
? update(createImportSpecifier(isTypeOnly, propertyName, name), node)
|
|
24471
24472
|
: node;
|
|
24472
24473
|
}
|
|
24473
24474
|
// @api
|
|
@@ -24528,8 +24529,9 @@ var ts;
|
|
|
24528
24529
|
: node;
|
|
24529
24530
|
}
|
|
24530
24531
|
// @api
|
|
24531
|
-
function createExportSpecifier(propertyName, name) {
|
|
24532
|
+
function createExportSpecifier(isTypeOnly, propertyName, name) {
|
|
24532
24533
|
var node = createBaseNode(274 /* ExportSpecifier */);
|
|
24534
|
+
node.isTypeOnly = isTypeOnly;
|
|
24533
24535
|
node.propertyName = asName(propertyName);
|
|
24534
24536
|
node.name = asName(name);
|
|
24535
24537
|
node.transformFlags |=
|
|
@@ -24539,10 +24541,11 @@ var ts;
|
|
|
24539
24541
|
return node;
|
|
24540
24542
|
}
|
|
24541
24543
|
// @api
|
|
24542
|
-
function updateExportSpecifier(node, propertyName, name) {
|
|
24543
|
-
return node.
|
|
24544
|
+
function updateExportSpecifier(node, isTypeOnly, propertyName, name) {
|
|
24545
|
+
return node.isTypeOnly !== isTypeOnly
|
|
24546
|
+
|| node.propertyName !== propertyName
|
|
24544
24547
|
|| node.name !== name
|
|
24545
|
-
? update(createExportSpecifier(propertyName, name), node)
|
|
24548
|
+
? update(createExportSpecifier(isTypeOnly, propertyName, name), node)
|
|
24546
24549
|
: node;
|
|
24547
24550
|
}
|
|
24548
24551
|
// @api
|
|
@@ -25650,7 +25653,7 @@ var ts;
|
|
|
25650
25653
|
/*decorators*/ undefined,
|
|
25651
25654
|
/*modifiers*/ undefined,
|
|
25652
25655
|
/*isTypeOnly*/ false, createNamedExports([
|
|
25653
|
-
createExportSpecifier(/*propertyName*/ undefined, exportName)
|
|
25656
|
+
createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, exportName)
|
|
25654
25657
|
]));
|
|
25655
25658
|
}
|
|
25656
25659
|
//
|
|
@@ -28917,8 +28920,8 @@ var ts;
|
|
|
28917
28920
|
// Alias the imports if the names are used somewhere in the file.
|
|
28918
28921
|
// NOTE: We don't need to care about global import collisions as this is a module.
|
|
28919
28922
|
namedBindings = nodeFactory.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name)
|
|
28920
|
-
? nodeFactory.createImportSpecifier(/*propertyName*/ undefined, nodeFactory.createIdentifier(name))
|
|
28921
|
-
: nodeFactory.createImportSpecifier(nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); }));
|
|
28923
|
+
? nodeFactory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, nodeFactory.createIdentifier(name))
|
|
28924
|
+
: nodeFactory.createImportSpecifier(/*isTypeOnly*/ false, nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); }));
|
|
28922
28925
|
var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
|
|
28923
28926
|
var emitNode = ts.getOrCreateEmitNode(parseNode);
|
|
28924
28927
|
emitNode.externalHelpers = true;
|
|
@@ -36045,27 +36048,74 @@ var ts;
|
|
|
36045
36048
|
var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
|
|
36046
36049
|
var checkIdentifierStart = scanner.getTokenPos();
|
|
36047
36050
|
var checkIdentifierEnd = scanner.getTextPos();
|
|
36048
|
-
var
|
|
36051
|
+
var isTypeOnly = false;
|
|
36049
36052
|
var propertyName;
|
|
36050
|
-
var
|
|
36051
|
-
|
|
36052
|
-
|
|
36053
|
-
|
|
36054
|
-
|
|
36055
|
-
|
|
36056
|
-
|
|
36057
|
-
|
|
36053
|
+
var canParseAsKeyword = true;
|
|
36054
|
+
var name = parseIdentifierName();
|
|
36055
|
+
if (name.escapedText === "type") {
|
|
36056
|
+
// If the first token of an import specifier is 'type', there are a lot of possibilities,
|
|
36057
|
+
// especially if we see 'as' afterwards:
|
|
36058
|
+
//
|
|
36059
|
+
// import { type } from "mod"; - isTypeOnly: false, name: type
|
|
36060
|
+
// import { type as } from "mod"; - isTypeOnly: true, name: as
|
|
36061
|
+
// import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type
|
|
36062
|
+
// import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as
|
|
36063
|
+
if (token() === 127 /* AsKeyword */) {
|
|
36064
|
+
// { type as ...? }
|
|
36065
|
+
var firstAs = parseIdentifierName();
|
|
36066
|
+
if (token() === 127 /* AsKeyword */) {
|
|
36067
|
+
// { type as as ...? }
|
|
36068
|
+
var secondAs = parseIdentifierName();
|
|
36069
|
+
if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
36070
|
+
// { type as as something }
|
|
36071
|
+
isTypeOnly = true;
|
|
36072
|
+
propertyName = firstAs;
|
|
36073
|
+
name = parseNameWithKeywordCheck();
|
|
36074
|
+
canParseAsKeyword = false;
|
|
36075
|
+
}
|
|
36076
|
+
else {
|
|
36077
|
+
// { type as as }
|
|
36078
|
+
propertyName = name;
|
|
36079
|
+
name = secondAs;
|
|
36080
|
+
canParseAsKeyword = false;
|
|
36081
|
+
}
|
|
36082
|
+
}
|
|
36083
|
+
else if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
36084
|
+
// { type as something }
|
|
36085
|
+
propertyName = name;
|
|
36086
|
+
canParseAsKeyword = false;
|
|
36087
|
+
name = parseNameWithKeywordCheck();
|
|
36088
|
+
}
|
|
36089
|
+
else {
|
|
36090
|
+
// { type as }
|
|
36091
|
+
isTypeOnly = true;
|
|
36092
|
+
name = firstAs;
|
|
36093
|
+
}
|
|
36094
|
+
}
|
|
36095
|
+
else if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
36096
|
+
// { type something ...? }
|
|
36097
|
+
isTypeOnly = true;
|
|
36098
|
+
name = parseNameWithKeywordCheck();
|
|
36099
|
+
}
|
|
36058
36100
|
}
|
|
36059
|
-
|
|
36060
|
-
|
|
36101
|
+
if (canParseAsKeyword && token() === 127 /* AsKeyword */) {
|
|
36102
|
+
propertyName = name;
|
|
36103
|
+
parseExpected(127 /* AsKeyword */);
|
|
36104
|
+
name = parseNameWithKeywordCheck();
|
|
36061
36105
|
}
|
|
36062
36106
|
if (kind === 269 /* ImportSpecifier */ && checkIdentifierIsKeyword) {
|
|
36063
36107
|
parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
|
|
36064
36108
|
}
|
|
36065
36109
|
var node = kind === 269 /* ImportSpecifier */
|
|
36066
|
-
? factory.createImportSpecifier(propertyName, name)
|
|
36067
|
-
: factory.createExportSpecifier(propertyName, name);
|
|
36110
|
+
? factory.createImportSpecifier(isTypeOnly, propertyName, name)
|
|
36111
|
+
: factory.createExportSpecifier(isTypeOnly, propertyName, name);
|
|
36068
36112
|
return finishNode(node, pos);
|
|
36113
|
+
function parseNameWithKeywordCheck() {
|
|
36114
|
+
checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
|
|
36115
|
+
checkIdentifierStart = scanner.getTokenPos();
|
|
36116
|
+
checkIdentifierEnd = scanner.getTextPos();
|
|
36117
|
+
return parseIdentifierName();
|
|
36118
|
+
}
|
|
36069
36119
|
}
|
|
36070
36120
|
function parseNamespaceExport(pos) {
|
|
36071
36121
|
return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos);
|
|
@@ -46895,6 +46945,7 @@ var ts;
|
|
|
46895
46945
|
getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
|
|
46896
46946
|
isDeclarationVisible: isDeclarationVisible,
|
|
46897
46947
|
isPropertyAccessible: isPropertyAccessible,
|
|
46948
|
+
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
46898
46949
|
};
|
|
46899
46950
|
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
|
|
46900
46951
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -48271,8 +48322,7 @@ var ts;
|
|
|
48271
48322
|
if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
|
|
48272
48323
|
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
|
|
48273
48324
|
if (typeOnlyDeclaration) {
|
|
48274
|
-
var
|
|
48275
|
-
var message = isExport
|
|
48325
|
+
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
48276
48326
|
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
48277
48327
|
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
48278
48328
|
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
@@ -48283,7 +48333,7 @@ var ts;
|
|
|
48283
48333
|
function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
|
|
48284
48334
|
if (!typeOnlyDeclaration)
|
|
48285
48335
|
return diagnostic;
|
|
48286
|
-
return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration,
|
|
48336
|
+
return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 274 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName));
|
|
48287
48337
|
}
|
|
48288
48338
|
function getIsDeferredContext(location, lastLocation) {
|
|
48289
48339
|
if (location.kind !== 213 /* ArrowFunction */ && location.kind !== 212 /* FunctionExpression */) {
|
|
@@ -48607,15 +48657,13 @@ var ts;
|
|
|
48607
48657
|
function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
|
|
48608
48658
|
if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) {
|
|
48609
48659
|
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
|
|
48610
|
-
var isExport =
|
|
48660
|
+
var isExport = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */;
|
|
48611
48661
|
var message = isExport
|
|
48612
48662
|
? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
|
|
48613
48663
|
: ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
|
|
48614
48664
|
var relatedMessage = isExport
|
|
48615
48665
|
? ts.Diagnostics._0_was_exported_here
|
|
48616
48666
|
: ts.Diagnostics._0_was_imported_here;
|
|
48617
|
-
// Non-null assertion is safe because the optionality comes from ImportClause,
|
|
48618
|
-
// but if an ImportClause was the typeOnlyDeclaration, it had to have a `name`.
|
|
48619
48667
|
var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
|
|
48620
48668
|
ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
|
|
48621
48669
|
}
|
|
@@ -49031,13 +49079,13 @@ var ts;
|
|
|
49031
49079
|
* and issue an error if so.
|
|
49032
49080
|
*
|
|
49033
49081
|
* @param aliasDeclaration The alias declaration not marked as type-only
|
|
49082
|
+
* @param immediateTarget The symbol to which the alias declaration immediately resolves
|
|
49083
|
+
* @param finalTarget The symbol to which the alias declaration ultimately resolves
|
|
49084
|
+
* @param overwriteEmpty Checks `resolvesToSymbol` for type-only declarations even if `aliasDeclaration`
|
|
49034
49085
|
* has already been marked as not resolving to a type-only alias. Used when recursively resolving qualified
|
|
49035
49086
|
* names of import aliases, e.g. `import C = a.b.C`. If namespace `a` is not found to be type-only, the
|
|
49036
49087
|
* import declaration will initially be marked as not resolving to a type-only symbol. But, namespace `b`
|
|
49037
49088
|
* must still be checked for a type-only marker, overwriting the previous negative result if found.
|
|
49038
|
-
* @param immediateTarget The symbol to which the alias declaration immediately resolves
|
|
49039
|
-
* @param finalTarget The symbol to which the alias declaration ultimately resolves
|
|
49040
|
-
* @param overwriteEmpty Checks `resolvesToSymbol` for type-only declarations even if `aliasDeclaration`
|
|
49041
49089
|
*/
|
|
49042
49090
|
function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) {
|
|
49043
49091
|
if (!aliasDeclaration || ts.isPropertyAccessExpression(aliasDeclaration))
|
|
@@ -52170,7 +52218,7 @@ var ts;
|
|
|
52170
52218
|
ns = ts.factory.updateModuleDeclaration(ns, ns.decorators, ns.modifiers, ns.name, body = ts.factory.updateModuleBlock(body, ts.factory.createNodeArray(__spreadArray(__spreadArray([], ns.body.statements, true), [ts.factory.createExportDeclaration(
|
|
52171
52219
|
/*decorators*/ undefined,
|
|
52172
52220
|
/*modifiers*/ undefined,
|
|
52173
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(/*alias*/ undefined, id); })),
|
|
52221
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, /*alias*/ undefined, id); })),
|
|
52174
52222
|
/*moduleSpecifier*/ undefined)], false))));
|
|
52175
52223
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, nsIndex), true), [ns], false), statements.slice(nsIndex + 1), true);
|
|
52176
52224
|
}
|
|
@@ -52398,7 +52446,7 @@ var ts;
|
|
|
52398
52446
|
addResult(ts.factory.createExportDeclaration(
|
|
52399
52447
|
/*decorators*/ undefined,
|
|
52400
52448
|
/*modifiers*/ undefined,
|
|
52401
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(alias, localName)])), 0 /* None */);
|
|
52449
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */);
|
|
52402
52450
|
context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */);
|
|
52403
52451
|
}
|
|
52404
52452
|
else {
|
|
@@ -52431,7 +52479,7 @@ var ts;
|
|
|
52431
52479
|
addResult(ts.factory.createExportDeclaration(
|
|
52432
52480
|
/*decorators*/ undefined,
|
|
52433
52481
|
/*modifiers*/ undefined,
|
|
52434
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(name, localName)])), 0 /* None */);
|
|
52482
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */);
|
|
52435
52483
|
needsExportDeclaration = false;
|
|
52436
52484
|
needsPostExportDefault = false;
|
|
52437
52485
|
}
|
|
@@ -52489,7 +52537,7 @@ var ts;
|
|
|
52489
52537
|
addResult(ts.factory.createExportDeclaration(
|
|
52490
52538
|
/*decorators*/ undefined,
|
|
52491
52539
|
/*modifiers*/ undefined,
|
|
52492
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */);
|
|
52540
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */);
|
|
52493
52541
|
}
|
|
52494
52542
|
}
|
|
52495
52543
|
function includePrivateSymbol(symbol) {
|
|
@@ -52611,7 +52659,7 @@ var ts;
|
|
|
52611
52659
|
var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true);
|
|
52612
52660
|
includePrivateSymbol(target || s);
|
|
52613
52661
|
var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName;
|
|
52614
|
-
return ts.factory.createExportSpecifier(name === targetName ? undefined : targetName, name);
|
|
52662
|
+
return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name);
|
|
52615
52663
|
})))]);
|
|
52616
52664
|
addResult(ts.factory.createModuleDeclaration(
|
|
52617
52665
|
/*decorators*/ undefined,
|
|
@@ -52702,7 +52750,7 @@ var ts;
|
|
|
52702
52750
|
var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration(
|
|
52703
52751
|
/*decorators*/ undefined,
|
|
52704
52752
|
/*modifiers*/ undefined,
|
|
52705
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; });
|
|
52753
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; });
|
|
52706
52754
|
var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced;
|
|
52707
52755
|
fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped));
|
|
52708
52756
|
addResult(fakespace, modifierFlags); // namespaces can never be default exported
|
|
@@ -52853,7 +52901,8 @@ var ts;
|
|
|
52853
52901
|
var propertyName = node.propertyName;
|
|
52854
52902
|
addResult(ts.factory.createImportDeclaration(
|
|
52855
52903
|
/*decorators*/ undefined,
|
|
52856
|
-
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(
|
|
52904
|
+
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(
|
|
52905
|
+
/*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1),
|
|
52857
52906
|
/*importClause*/ undefined), 0 /* None */);
|
|
52858
52907
|
break;
|
|
52859
52908
|
}
|
|
@@ -52937,7 +52986,8 @@ var ts;
|
|
|
52937
52986
|
/*modifiers*/ undefined, ts.factory.createImportClause(
|
|
52938
52987
|
/*isTypeOnly*/ false,
|
|
52939
52988
|
/*importClause*/ undefined, ts.factory.createNamedImports([
|
|
52940
|
-
ts.factory.createImportSpecifier(
|
|
52989
|
+
ts.factory.createImportSpecifier(
|
|
52990
|
+
/*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName))
|
|
52941
52991
|
])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
|
|
52942
52992
|
/*assertClause*/ undefined), 0 /* None */);
|
|
52943
52993
|
break;
|
|
@@ -52973,7 +53023,7 @@ var ts;
|
|
|
52973
53023
|
addResult(ts.factory.createExportDeclaration(
|
|
52974
53024
|
/*decorators*/ undefined,
|
|
52975
53025
|
/*modifiers*/ undefined,
|
|
52976
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */);
|
|
53026
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */);
|
|
52977
53027
|
}
|
|
52978
53028
|
/**
|
|
52979
53029
|
* Returns `true` if an export assignment or declaration was produced for the symbol
|
|
@@ -56468,6 +56518,23 @@ var ts;
|
|
|
56468
56518
|
function getIsLateCheckFlag(s) {
|
|
56469
56519
|
return ts.getCheckFlags(s) & 4096 /* Late */;
|
|
56470
56520
|
}
|
|
56521
|
+
function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) {
|
|
56522
|
+
for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
|
|
56523
|
+
var prop = _a[_i];
|
|
56524
|
+
cb(getLiteralTypeFromProperty(prop, include));
|
|
56525
|
+
}
|
|
56526
|
+
if (type.flags & 1 /* Any */) {
|
|
56527
|
+
cb(stringType);
|
|
56528
|
+
}
|
|
56529
|
+
else {
|
|
56530
|
+
for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) {
|
|
56531
|
+
var info = _c[_b];
|
|
56532
|
+
if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
56533
|
+
cb(info.keyType);
|
|
56534
|
+
}
|
|
56535
|
+
}
|
|
56536
|
+
}
|
|
56537
|
+
}
|
|
56471
56538
|
/** Resolve the members of a mapped type { [P in K]: T } */
|
|
56472
56539
|
function resolveMappedTypeMembers(type) {
|
|
56473
56540
|
var members = ts.createSymbolTable();
|
|
@@ -56485,21 +56552,7 @@ var ts;
|
|
|
56485
56552
|
var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
|
|
56486
56553
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
56487
56554
|
// We have a { [P in keyof T]: X }
|
|
56488
|
-
|
|
56489
|
-
var prop = _a[_i];
|
|
56490
|
-
addMemberForKeyType(getLiteralTypeFromProperty(prop, include));
|
|
56491
|
-
}
|
|
56492
|
-
if (modifiersType.flags & 1 /* Any */) {
|
|
56493
|
-
addMemberForKeyType(stringType);
|
|
56494
|
-
}
|
|
56495
|
-
else {
|
|
56496
|
-
for (var _b = 0, _c = getIndexInfosOfType(modifiersType); _b < _c.length; _b++) {
|
|
56497
|
-
var info = _c[_b];
|
|
56498
|
-
if (!keyofStringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
56499
|
-
addMemberForKeyType(info.keyType);
|
|
56500
|
-
}
|
|
56501
|
-
}
|
|
56502
|
-
}
|
|
56555
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
|
|
56503
56556
|
}
|
|
56504
56557
|
else {
|
|
56505
56558
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
@@ -59616,18 +59669,56 @@ var ts;
|
|
|
59616
59669
|
type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) :
|
|
59617
59670
|
type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false));
|
|
59618
59671
|
}
|
|
59619
|
-
|
|
59620
|
-
|
|
59621
|
-
|
|
59622
|
-
|
|
59623
|
-
|
|
59624
|
-
|
|
59625
|
-
|
|
59626
|
-
|
|
59627
|
-
var
|
|
59628
|
-
|
|
59629
|
-
|
|
59630
|
-
|
|
59672
|
+
/**
|
|
59673
|
+
* This roughly mirrors `resolveMappedTypeMembers` in the nongeneric case, except only reports a union of the keys calculated,
|
|
59674
|
+
* rather than manufacturing the properties. We can't just fetch the `constraintType` since that would ignore mappings
|
|
59675
|
+
* and mapping the `constraintType` directly ignores how mapped types map _properties_ and not keys (thus ignoring subtype
|
|
59676
|
+
* reduction in the constraintType) when possible.
|
|
59677
|
+
* @param noIndexSignatures Indicates if _string_ index signatures should be elided. (other index signatures are always reported)
|
|
59678
|
+
*/
|
|
59679
|
+
function getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) {
|
|
59680
|
+
var typeParameter = getTypeParameterFromMappedType(type);
|
|
59681
|
+
var constraintType = getConstraintTypeFromMappedType(type);
|
|
59682
|
+
var nameType = getNameTypeFromMappedType(type.target || type);
|
|
59683
|
+
if (!nameType && !noIndexSignatures) {
|
|
59684
|
+
// no mapping and no filtering required, just quickly bail to returning the constraint in the common case
|
|
59685
|
+
return constraintType;
|
|
59686
|
+
}
|
|
59687
|
+
var keyTypes = [];
|
|
59688
|
+
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
59689
|
+
// We have a { [P in keyof T]: X }
|
|
59690
|
+
// `getApparentType` on the T in a generic mapped type can trigger a circularity
|
|
59691
|
+
// (conditionals and `infer` types create a circular dependency in the constraint resolution)
|
|
59692
|
+
// so we only eagerly manifest the keys if the constraint is nongeneric
|
|
59693
|
+
if (!isGenericIndexType(constraintType)) {
|
|
59694
|
+
var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T'
|
|
59695
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType);
|
|
59696
|
+
}
|
|
59697
|
+
else {
|
|
59698
|
+
// we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later
|
|
59699
|
+
// since it's not safe to resolve the shape of modifier type
|
|
59700
|
+
return getIndexTypeForGenericType(type, stringsOnly);
|
|
59701
|
+
}
|
|
59702
|
+
}
|
|
59703
|
+
else {
|
|
59704
|
+
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
59705
|
+
}
|
|
59706
|
+
if (isGenericIndexType(constraintType)) { // include the generic component in the resulting type
|
|
59707
|
+
forEachType(constraintType, addMemberForKeyType);
|
|
59708
|
+
}
|
|
59709
|
+
// we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType,
|
|
59710
|
+
// so we can return the union that preserves aliases/origin data if possible
|
|
59711
|
+
var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes);
|
|
59712
|
+
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
59713
|
+
return constraintType;
|
|
59714
|
+
}
|
|
59715
|
+
return result;
|
|
59716
|
+
function addMemberForKeyType(keyType) {
|
|
59717
|
+
var propNameType = nameType ? instantiateType(nameType, appendTypeMapping(type.mapper, typeParameter, keyType)) : keyType;
|
|
59718
|
+
// `keyof` currently always returns `string | number` for concrete `string` index signatures - the below ternary keeps that behavior for mapped types
|
|
59719
|
+
// See `getLiteralTypeFromProperties` where there's a similar ternary to cause the same behavior.
|
|
59720
|
+
keyTypes.push(propNameType === stringType ? stringOrNumberType : propNameType);
|
|
59721
|
+
}
|
|
59631
59722
|
}
|
|
59632
59723
|
// Ordinarily we reduce a keyof M, where M is a mapped type { [P in K as N<P>]: X }, to simply N<K>. This however presumes
|
|
59633
59724
|
// that N distributes over union types, i.e. that N<A | B | C> is equivalent to N<A> | N<B> | N<C>. Specifically, we only
|
|
@@ -59685,7 +59776,7 @@ var ts;
|
|
|
59685
59776
|
return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
59686
59777
|
type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
59687
59778
|
type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
|
|
59688
|
-
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) :
|
|
59779
|
+
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
|
|
59689
59780
|
type === wildcardType ? wildcardType :
|
|
59690
59781
|
type.flags & 2 /* Unknown */ ? neverType :
|
|
59691
59782
|
type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType :
|
|
@@ -63444,24 +63535,24 @@ var ts;
|
|
|
63444
63535
|
}
|
|
63445
63536
|
}
|
|
63446
63537
|
else if (target.flags & 4194304 /* Index */) {
|
|
63447
|
-
var
|
|
63538
|
+
var targetType_1 = target.type;
|
|
63448
63539
|
// A keyof S is related to a keyof T if T is related to S.
|
|
63449
63540
|
if (source.flags & 4194304 /* Index */) {
|
|
63450
|
-
if (result = isRelatedTo(
|
|
63541
|
+
if (result = isRelatedTo(targetType_1, source.type, /*reportErrors*/ false)) {
|
|
63451
63542
|
return result;
|
|
63452
63543
|
}
|
|
63453
63544
|
}
|
|
63454
|
-
if (isTupleType(
|
|
63545
|
+
if (isTupleType(targetType_1)) {
|
|
63455
63546
|
// An index type can have a tuple type target when the tuple type contains variadic elements.
|
|
63456
63547
|
// Check if the source is related to the known keys of the tuple type.
|
|
63457
|
-
if (result = isRelatedTo(source, getKnownKeysOfTupleType(
|
|
63548
|
+
if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), reportErrors)) {
|
|
63458
63549
|
return result;
|
|
63459
63550
|
}
|
|
63460
63551
|
}
|
|
63461
63552
|
else {
|
|
63462
63553
|
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
|
|
63463
63554
|
// simplified form of T or, if T doesn't simplify, the constraint of T.
|
|
63464
|
-
var constraint = getSimplifiedTypeOrConstraint(
|
|
63555
|
+
var constraint = getSimplifiedTypeOrConstraint(targetType_1);
|
|
63465
63556
|
if (constraint) {
|
|
63466
63557
|
// We require Ternary.True here such that circular constraints don't cause
|
|
63467
63558
|
// false positives. For example, given 'T extends { [K in keyof T]: string }',
|
|
@@ -63471,6 +63562,30 @@ var ts;
|
|
|
63471
63562
|
return -1 /* True */;
|
|
63472
63563
|
}
|
|
63473
63564
|
}
|
|
63565
|
+
else if (isGenericMappedType(targetType_1)) {
|
|
63566
|
+
// generic mapped types that don't simplify or have a constraint still have a very simple set of keys we can compare against
|
|
63567
|
+
// - their nameType or constraintType.
|
|
63568
|
+
// In many ways, this comparison is a deferred version of what `getIndexTypeForMappedType` does to actually resolve the keys for _non_-generic types
|
|
63569
|
+
var nameType_1 = getNameTypeFromMappedType(targetType_1);
|
|
63570
|
+
var constraintType = getConstraintTypeFromMappedType(targetType_1);
|
|
63571
|
+
var targetKeys = void 0;
|
|
63572
|
+
if (nameType_1 && isMappedTypeWithKeyofConstraintDeclaration(targetType_1)) {
|
|
63573
|
+
// we need to get the apparent mappings and union them with the generic mappings, since some properties may be
|
|
63574
|
+
// missing from the `constraintType` which will otherwise be mapped in the object
|
|
63575
|
+
var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1));
|
|
63576
|
+
var mappedKeys_1 = [];
|
|
63577
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */,
|
|
63578
|
+
/*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); });
|
|
63579
|
+
// We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side)
|
|
63580
|
+
targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false));
|
|
63581
|
+
}
|
|
63582
|
+
else {
|
|
63583
|
+
targetKeys = nameType_1 || constraintType;
|
|
63584
|
+
}
|
|
63585
|
+
if (isRelatedTo(source, targetKeys, reportErrors) === -1 /* True */) {
|
|
63586
|
+
return -1 /* True */;
|
|
63587
|
+
}
|
|
63588
|
+
}
|
|
63474
63589
|
}
|
|
63475
63590
|
}
|
|
63476
63591
|
else if (target.flags & 8388608 /* IndexedAccess */) {
|
|
@@ -66501,8 +66616,16 @@ var ts;
|
|
|
66501
66616
|
function inferToTemplateLiteralType(source, target) {
|
|
66502
66617
|
var matches = inferTypesFromTemplateLiteralType(source, target);
|
|
66503
66618
|
var types = target.types;
|
|
66504
|
-
|
|
66505
|
-
|
|
66619
|
+
// When the target template literal contains only placeholders (meaning that inference is intended to extract
|
|
66620
|
+
// single characters and remainder strings) and inference fails to produce matches, we want to infer 'never' for
|
|
66621
|
+
// each placeholder such that instantiation with the inferred value(s) produces 'never', a type for which an
|
|
66622
|
+
// assignment check will fail. If we make no inferences, we'll likely end up with the constraint 'string' which,
|
|
66623
|
+
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
66624
|
+
// succeed. That would be a pointless and confusing outcome.
|
|
66625
|
+
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
66626
|
+
for (var i = 0; i < types.length; i++) {
|
|
66627
|
+
inferFromTypes(matches ? matches[i] : neverType, types[i]);
|
|
66628
|
+
}
|
|
66506
66629
|
}
|
|
66507
66630
|
}
|
|
66508
66631
|
function inferFromObjectTypes(source, target) {
|
|
@@ -70219,9 +70342,9 @@ var ts;
|
|
|
70219
70342
|
return getTypeOfPropertyOfContextualType(type, getSymbolOfNode(element).escapedName);
|
|
70220
70343
|
}
|
|
70221
70344
|
if (element.name) {
|
|
70222
|
-
var
|
|
70345
|
+
var nameType_2 = getLiteralTypeFromPropertyName(element.name);
|
|
70223
70346
|
// We avoid calling getApplicableIndexInfo here because it performs potentially expensive intersection reduction.
|
|
70224
|
-
return mapType(type, function (t) { var _a; return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t),
|
|
70347
|
+
return mapType(type, function (t) { var _a; return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType_2)) === null || _a === void 0 ? void 0 : _a.type; }, /*noReductions*/ true);
|
|
70225
70348
|
}
|
|
70226
70349
|
}
|
|
70227
70350
|
return undefined;
|
|
@@ -82364,11 +82487,15 @@ var ts;
|
|
|
82364
82487
|
}
|
|
82365
82488
|
function checkGrammarExportDeclaration(node) {
|
|
82366
82489
|
var _a;
|
|
82367
|
-
|
|
82368
|
-
|
|
82369
|
-
|
|
82490
|
+
if (node.isTypeOnly) {
|
|
82491
|
+
if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 272 /* NamedExports */) {
|
|
82492
|
+
return checkGrammarNamedImportsOrExports(node.exportClause);
|
|
82493
|
+
}
|
|
82494
|
+
else {
|
|
82495
|
+
return grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
|
|
82496
|
+
}
|
|
82370
82497
|
}
|
|
82371
|
-
return
|
|
82498
|
+
return false;
|
|
82372
82499
|
}
|
|
82373
82500
|
function checkGrammarModuleElementContext(node, errorMessage) {
|
|
82374
82501
|
var isInAppropriateContext = node.parent.kind === 303 /* SourceFile */ || node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 260 /* ModuleDeclaration */;
|
|
@@ -86043,11 +86170,24 @@ var ts;
|
|
|
86043
86170
|
return ambientModulesCache;
|
|
86044
86171
|
}
|
|
86045
86172
|
function checkGrammarImportClause(node) {
|
|
86173
|
+
var _a;
|
|
86046
86174
|
if (node.isTypeOnly && node.name && node.namedBindings) {
|
|
86047
86175
|
return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
|
|
86048
86176
|
}
|
|
86177
|
+
if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamedImports */) {
|
|
86178
|
+
return checkGrammarNamedImportsOrExports(node.namedBindings);
|
|
86179
|
+
}
|
|
86049
86180
|
return false;
|
|
86050
86181
|
}
|
|
86182
|
+
function checkGrammarNamedImportsOrExports(namedBindings) {
|
|
86183
|
+
return !!ts.forEach(namedBindings.elements, function (specifier) {
|
|
86184
|
+
if (specifier.isTypeOnly) {
|
|
86185
|
+
return grammarErrorOnFirstToken(specifier, specifier.kind === 269 /* ImportSpecifier */
|
|
86186
|
+
? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement
|
|
86187
|
+
: ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement);
|
|
86188
|
+
}
|
|
86189
|
+
});
|
|
86190
|
+
}
|
|
86051
86191
|
function checkGrammarImportCallExpression(node) {
|
|
86052
86192
|
if (moduleKind === ts.ModuleKind.ES2015) {
|
|
86053
86193
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_umd_node12_or_nodenext);
|
|
@@ -86779,7 +86919,7 @@ var ts;
|
|
|
86779
86919
|
return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
|
|
86780
86920
|
case 269 /* ImportSpecifier */:
|
|
86781
86921
|
ts.Debug.type(node);
|
|
86782
|
-
return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86922
|
+
return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86783
86923
|
case 270 /* ExportAssignment */:
|
|
86784
86924
|
ts.Debug.type(node);
|
|
86785
86925
|
return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression));
|
|
@@ -86791,7 +86931,7 @@ var ts;
|
|
|
86791
86931
|
return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
|
|
86792
86932
|
case 274 /* ExportSpecifier */:
|
|
86793
86933
|
ts.Debug.type(node);
|
|
86794
|
-
return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86934
|
+
return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86795
86935
|
// Module references
|
|
86796
86936
|
case 276 /* ExternalModuleReference */:
|
|
86797
86937
|
ts.Debug.type(node);
|
|
@@ -90732,9 +90872,11 @@ var ts;
|
|
|
90732
90872
|
return shouldEmitAliasDeclaration(node) ? node : undefined;
|
|
90733
90873
|
}
|
|
90734
90874
|
else {
|
|
90735
|
-
// Elide named imports if all of its import specifiers are elided.
|
|
90875
|
+
// Elide named imports if all of its import specifiers are elided and settings allow.
|
|
90876
|
+
var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ ||
|
|
90877
|
+
compilerOptions.importsNotUsedAsValues === 2 /* Error */);
|
|
90736
90878
|
var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
|
|
90737
|
-
return ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
|
|
90879
|
+
return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
|
|
90738
90880
|
}
|
|
90739
90881
|
}
|
|
90740
90882
|
/**
|
|
@@ -90743,7 +90885,7 @@ var ts;
|
|
|
90743
90885
|
* @param node The import specifier node.
|
|
90744
90886
|
*/
|
|
90745
90887
|
function visitImportSpecifier(node) {
|
|
90746
|
-
return shouldEmitAliasDeclaration(node) ? node : undefined;
|
|
90888
|
+
return !node.isTypeOnly && shouldEmitAliasDeclaration(node) ? node : undefined;
|
|
90747
90889
|
}
|
|
90748
90890
|
/**
|
|
90749
90891
|
* Visits an export assignment, eliding it if it does not contain a clause that resolves
|
|
@@ -90772,12 +90914,10 @@ var ts;
|
|
|
90772
90914
|
// type checker doesn't know about any exports
|
|
90773
90915
|
return node;
|
|
90774
90916
|
}
|
|
90775
|
-
if (!resolver.isValueAliasDeclaration(node)) {
|
|
90776
|
-
// Elide the export declaration if it does not export a value.
|
|
90777
|
-
return undefined;
|
|
90778
|
-
}
|
|
90779
90917
|
// Elide the export declaration if all of its named exports are elided.
|
|
90780
|
-
var
|
|
90918
|
+
var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ ||
|
|
90919
|
+
compilerOptions.importsNotUsedAsValues === 2 /* Error */);
|
|
90920
|
+
var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings);
|
|
90781
90921
|
return exportClause
|
|
90782
90922
|
? factory.updateExportDeclaration(node,
|
|
90783
90923
|
/*decorators*/ undefined,
|
|
@@ -90790,16 +90930,16 @@ var ts;
|
|
|
90790
90930
|
*
|
|
90791
90931
|
* @param node The named exports node.
|
|
90792
90932
|
*/
|
|
90793
|
-
function visitNamedExports(node) {
|
|
90933
|
+
function visitNamedExports(node, allowEmpty) {
|
|
90794
90934
|
// Elide the named exports if all of its export specifiers were elided.
|
|
90795
90935
|
var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
|
|
90796
|
-
return ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined;
|
|
90936
|
+
return allowEmpty || ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined;
|
|
90797
90937
|
}
|
|
90798
90938
|
function visitNamespaceExports(node) {
|
|
90799
90939
|
return factory.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
|
|
90800
90940
|
}
|
|
90801
|
-
function visitNamedExportBindings(node) {
|
|
90802
|
-
return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
|
|
90941
|
+
function visitNamedExportBindings(node, allowEmpty) {
|
|
90942
|
+
return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node, allowEmpty);
|
|
90803
90943
|
}
|
|
90804
90944
|
/**
|
|
90805
90945
|
* Visits an export specifier, eliding it if it does not resolve to a value.
|
|
@@ -90808,7 +90948,7 @@ var ts;
|
|
|
90808
90948
|
*/
|
|
90809
90949
|
function visitExportSpecifier(node) {
|
|
90810
90950
|
// Elide an export specifier if it does not reference a value.
|
|
90811
|
-
return resolver.isValueAliasDeclaration(node) ? node : undefined;
|
|
90951
|
+
return !node.isTypeOnly && resolver.isValueAliasDeclaration(node) ? node : undefined;
|
|
90812
90952
|
}
|
|
90813
90953
|
/**
|
|
90814
90954
|
* Determines whether to emit an import equals declaration.
|
|
@@ -94409,7 +94549,7 @@ var ts;
|
|
|
94409
94549
|
currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
|
|
94410
94550
|
}
|
|
94411
94551
|
var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */);
|
|
94412
|
-
var specifier = factory.createImportSpecifier(factory.createIdentifier(name), generatedName);
|
|
94552
|
+
var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName);
|
|
94413
94553
|
generatedName.generatedImportReference = specifier;
|
|
94414
94554
|
specifierSourceImports.set(name, specifier);
|
|
94415
94555
|
return generatedName;
|
|
@@ -104125,7 +104265,7 @@ var ts;
|
|
|
104125
104265
|
/*modifiers*/ undefined, factory.createImportClause(
|
|
104126
104266
|
/*isTypeOnly*/ false,
|
|
104127
104267
|
/*name*/ undefined, factory.createNamedImports([
|
|
104128
|
-
factory.createImportSpecifier(factory.createIdentifier("createRequire"), createRequireName)
|
|
104268
|
+
factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName)
|
|
104129
104269
|
])), factory.createStringLiteral("module"));
|
|
104130
104270
|
var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
104131
104271
|
var requireStatement = factory.createVariableStatement(
|
|
@@ -104165,7 +104305,7 @@ var ts;
|
|
|
104165
104305
|
if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
|
|
104166
104306
|
statements = ts.append(statements, factory.createExportDeclaration(
|
|
104167
104307
|
/*decorators*/ undefined,
|
|
104168
|
-
/*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*propertyName*/ undefined, ts.idText(node.name))])));
|
|
104308
|
+
/*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))])));
|
|
104169
104309
|
}
|
|
104170
104310
|
return statements;
|
|
104171
104311
|
}
|
|
@@ -104193,7 +104333,7 @@ var ts;
|
|
|
104193
104333
|
var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration(
|
|
104194
104334
|
/*decorators*/ undefined,
|
|
104195
104335
|
/*modifiers*/ undefined,
|
|
104196
|
-
/*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(synthName, oldIdentifier)]));
|
|
104336
|
+
/*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, synthName, oldIdentifier)]));
|
|
104197
104337
|
ts.setOriginalNode(exportDecl, node);
|
|
104198
104338
|
return [importDecl, exportDecl];
|
|
104199
104339
|
}
|
|
@@ -105760,7 +105900,7 @@ var ts;
|
|
|
105760
105900
|
/*modifiers*/ undefined,
|
|
105761
105901
|
/*isTypeOnly*/ false, factory.createNamedExports(ts.map(exportMappings_1, function (_a) {
|
|
105762
105902
|
var gen = _a[0], exp = _a[1];
|
|
105763
|
-
return factory.createExportSpecifier(gen, exp);
|
|
105903
|
+
return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp);
|
|
105764
105904
|
}))));
|
|
105765
105905
|
}
|
|
105766
105906
|
var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */);
|
|
@@ -109699,6 +109839,10 @@ var ts;
|
|
|
109699
109839
|
writePunctuation("}");
|
|
109700
109840
|
}
|
|
109701
109841
|
function emitImportOrExportSpecifier(node) {
|
|
109842
|
+
if (node.isTypeOnly) {
|
|
109843
|
+
writeKeyword("type");
|
|
109844
|
+
writeSpace();
|
|
109845
|
+
}
|
|
109702
109846
|
if (node.propertyName) {
|
|
109703
109847
|
emit(node.propertyName);
|
|
109704
109848
|
writeSpace();
|