typescript 4.7.0-dev.20220309 → 4.7.0-dev.20220310
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/tsc.js +138 -69
- package/lib/tsserver.js +185 -84
- package/lib/tsserverlibrary.d.ts +3 -1
- package/lib/tsserverlibrary.js +185 -84
- package/lib/typescript.d.ts +3 -1
- package/lib/typescript.js +185 -84
- package/lib/typescriptServices.d.ts +3 -1
- package/lib/typescriptServices.js +185 -84
- package/lib/typingsInstaller.js +185 -84
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220310";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -4164,6 +4164,7 @@ var ts;
|
|
|
4164
4164
|
SyntaxKind[SyntaxKind["JSDocFunctionType"] = 316] = "JSDocFunctionType";
|
|
4165
4165
|
SyntaxKind[SyntaxKind["JSDocVariadicType"] = 317] = "JSDocVariadicType";
|
|
4166
4166
|
SyntaxKind[SyntaxKind["JSDocNamepathType"] = 318] = "JSDocNamepathType";
|
|
4167
|
+
/** @deprecated Use SyntaxKind.JSDoc */
|
|
4167
4168
|
SyntaxKind[SyntaxKind["JSDocComment"] = 319] = "JSDocComment";
|
|
4168
4169
|
SyntaxKind[SyntaxKind["JSDocText"] = 320] = "JSDocText";
|
|
4169
4170
|
SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 321] = "JSDocTypeLiteral";
|
|
@@ -4237,6 +4238,7 @@ var ts;
|
|
|
4237
4238
|
SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 346] = "LastJSDocTagNode";
|
|
4238
4239
|
/* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
|
|
4239
4240
|
/* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 159] = "LastContextualKeyword";
|
|
4241
|
+
SyntaxKind[SyntaxKind["JSDoc"] = 319] = "JSDoc";
|
|
4240
4242
|
})(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
|
|
4241
4243
|
var NodeFlags;
|
|
4242
4244
|
(function (NodeFlags) {
|
|
@@ -12833,7 +12835,7 @@ var ts;
|
|
|
12833
12835
|
return ts.emptyArray;
|
|
12834
12836
|
}
|
|
12835
12837
|
if (ts.isJSDocTypeAlias(node)) {
|
|
12836
|
-
ts.Debug.assert(node.parent.kind === 319 /*
|
|
12838
|
+
ts.Debug.assert(node.parent.kind === 319 /* JSDoc */);
|
|
12837
12839
|
return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
|
|
12838
12840
|
}
|
|
12839
12841
|
if (node.typeParameters) {
|
|
@@ -13780,7 +13782,7 @@ var ts;
|
|
|
13780
13782
|
ts.isJSDocNode = isJSDocNode;
|
|
13781
13783
|
/** True if node is of a kind that may contain comment text. */
|
|
13782
13784
|
function isJSDocCommentContainingNode(node) {
|
|
13783
|
-
return node.kind === 319 /*
|
|
13785
|
+
return node.kind === 319 /* JSDoc */
|
|
13784
13786
|
|| node.kind === 318 /* JSDocNamepathType */
|
|
13785
13787
|
|| node.kind === 320 /* JSDocText */
|
|
13786
13788
|
|| isJSDocLinkLike(node)
|
|
@@ -15345,10 +15347,23 @@ var ts;
|
|
|
15345
15347
|
&& node.parent.parent.kind === 236 /* VariableStatement */;
|
|
15346
15348
|
}
|
|
15347
15349
|
ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
|
|
15350
|
+
function isCommonJsExportedExpression(node) {
|
|
15351
|
+
if (!isInJSFile(node))
|
|
15352
|
+
return false;
|
|
15353
|
+
return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) ||
|
|
15354
|
+
isCommonJsExportPropertyAssignment(node.parent);
|
|
15355
|
+
}
|
|
15356
|
+
ts.isCommonJsExportedExpression = isCommonJsExportedExpression;
|
|
15357
|
+
function isCommonJsExportPropertyAssignment(node) {
|
|
15358
|
+
if (!isInJSFile(node))
|
|
15359
|
+
return false;
|
|
15360
|
+
return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */);
|
|
15361
|
+
}
|
|
15362
|
+
ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment;
|
|
15348
15363
|
function isValidESSymbolDeclaration(node) {
|
|
15349
|
-
return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
|
|
15364
|
+
return (ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
|
|
15350
15365
|
ts.isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
|
|
15351
|
-
ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node);
|
|
15366
|
+
ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node)) || isCommonJsExportPropertyAssignment(node);
|
|
15352
15367
|
}
|
|
15353
15368
|
ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
|
|
15354
15369
|
function introducesArgumentsExoticObject(node) {
|
|
@@ -18242,7 +18257,7 @@ var ts;
|
|
|
18242
18257
|
ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
|
|
18243
18258
|
/** template tags are only available when a typedef isn't already using them */
|
|
18244
18259
|
function isNonTypeAliasTemplate(tag) {
|
|
18245
|
-
return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 319 /*
|
|
18260
|
+
return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 319 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias));
|
|
18246
18261
|
}
|
|
18247
18262
|
/**
|
|
18248
18263
|
* Gets the effective type annotation of the value parameter of a set accessor. If the node
|
|
@@ -25219,7 +25234,7 @@ var ts;
|
|
|
25219
25234
|
}
|
|
25220
25235
|
// @api
|
|
25221
25236
|
function createJSDocComment(comment, tags) {
|
|
25222
|
-
var node = createBaseNode(319 /*
|
|
25237
|
+
var node = createBaseNode(319 /* JSDoc */);
|
|
25223
25238
|
node.comment = comment;
|
|
25224
25239
|
node.tags = asNodeArray(tags);
|
|
25225
25240
|
return node;
|
|
@@ -28728,7 +28743,7 @@ var ts;
|
|
|
28728
28743
|
}
|
|
28729
28744
|
ts.isJSDocNamepathType = isJSDocNamepathType;
|
|
28730
28745
|
function isJSDoc(node) {
|
|
28731
|
-
return node.kind === 319 /*
|
|
28746
|
+
return node.kind === 319 /* JSDoc */;
|
|
28732
28747
|
}
|
|
28733
28748
|
ts.isJSDoc = isJSDoc;
|
|
28734
28749
|
function isJSDocTypeLiteral(node) {
|
|
@@ -30353,7 +30368,7 @@ var ts;
|
|
|
30353
30368
|
case 316 /* JSDocFunctionType */:
|
|
30354
30369
|
return visitNodes(cbNode, cbNodes, node.parameters) ||
|
|
30355
30370
|
visitNode(cbNode, node.type);
|
|
30356
|
-
case 319 /*
|
|
30371
|
+
case 319 /* JSDoc */:
|
|
30357
30372
|
return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))
|
|
30358
30373
|
|| visitNodes(cbNode, cbNodes, node.tags);
|
|
30359
30374
|
case 345 /* JSDocSeeTag */:
|
|
@@ -47667,6 +47682,8 @@ var ts;
|
|
|
47667
47682
|
var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
|
|
47668
47683
|
var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
|
|
47669
47684
|
var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
|
|
47685
|
+
var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
|
|
47686
|
+
var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints)
|
|
47670
47687
|
var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
47671
47688
|
var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
47672
47689
|
emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */;
|
|
@@ -48605,7 +48622,7 @@ var ts;
|
|
|
48605
48622
|
// - parameters are only in the scope of function body
|
|
48606
48623
|
// This restriction does not apply to JSDoc comment types because they are parented
|
|
48607
48624
|
// at a higher level than type parameters would normally be
|
|
48608
|
-
if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 319 /*
|
|
48625
|
+
if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 319 /* JSDoc */) {
|
|
48609
48626
|
useResult = result.flags & 262144 /* TypeParameter */
|
|
48610
48627
|
// type parameters are visible in parameter list, return type and type parameter list
|
|
48611
48628
|
? lastLocation === location.type ||
|
|
@@ -51571,10 +51588,16 @@ var ts;
|
|
|
51571
51588
|
var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
|
|
51572
51589
|
var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined;
|
|
51573
51590
|
var appropriateConstraintTypeNode;
|
|
51591
|
+
var newTypeVariable;
|
|
51574
51592
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
51575
51593
|
// We have a { [P in keyof T]: X }
|
|
51576
51594
|
// We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
|
|
51577
|
-
|
|
51595
|
+
if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
51596
|
+
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
51597
|
+
var name = typeParameterToName(newParam, context);
|
|
51598
|
+
newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
51599
|
+
}
|
|
51600
|
+
appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
|
|
51578
51601
|
}
|
|
51579
51602
|
else {
|
|
51580
51603
|
appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
|
|
@@ -51584,7 +51607,14 @@ var ts;
|
|
|
51584
51607
|
var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context);
|
|
51585
51608
|
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
|
|
51586
51609
|
context.approximateLength += 10;
|
|
51587
|
-
|
|
51610
|
+
var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
|
|
51611
|
+
if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
51612
|
+
// homomorphic mapped type with a non-homomorphic naive inlining
|
|
51613
|
+
// wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
|
|
51614
|
+
// type stays homomorphic
|
|
51615
|
+
return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
|
|
51616
|
+
}
|
|
51617
|
+
return result;
|
|
51588
51618
|
}
|
|
51589
51619
|
function createAnonymousTypeNode(type) {
|
|
51590
51620
|
var _a;
|
|
@@ -53205,7 +53235,7 @@ var ts;
|
|
|
53205
53235
|
// If it's a class/interface/function: emit a class/interface/function with a `default` modifier
|
|
53206
53236
|
// These forms can merge, eg (`export default 12; export default interface A {}`)
|
|
53207
53237
|
function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
|
|
53208
|
-
var _a, _b;
|
|
53238
|
+
var _a, _b, _c, _d;
|
|
53209
53239
|
var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
|
|
53210
53240
|
var isDefault = symbol.escapedName === "default" /* Default */;
|
|
53211
53241
|
if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
|
|
@@ -53256,17 +53286,21 @@ var ts;
|
|
|
53256
53286
|
else {
|
|
53257
53287
|
// A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_
|
|
53258
53288
|
// `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property`
|
|
53259
|
-
var flags = !(symbol.flags & 2 /* BlockScopedVariable */)
|
|
53260
|
-
:
|
|
53289
|
+
var flags = !(symbol.flags & 2 /* BlockScopedVariable */)
|
|
53290
|
+
? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration)
|
|
53291
|
+
? 2 /* Const */
|
|
53292
|
+
: undefined
|
|
53293
|
+
: isConstVariable(symbol)
|
|
53294
|
+
? 2 /* Const */
|
|
53261
53295
|
: 1 /* Let */;
|
|
53262
53296
|
var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol);
|
|
53263
53297
|
var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
|
|
53264
53298
|
if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
|
|
53265
53299
|
textRange = textRange.parent.parent;
|
|
53266
53300
|
}
|
|
53267
|
-
var propertyAccessRequire = (
|
|
53301
|
+
var propertyAccessRequire = (_c = symbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isPropertyAccessExpression);
|
|
53268
53302
|
if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right)
|
|
53269
|
-
&& ((
|
|
53303
|
+
&& ((_d = type.symbol) === null || _d === void 0 ? void 0 : _d.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
|
|
53270
53304
|
var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right;
|
|
53271
53305
|
addResult(ts.factory.createExportDeclaration(
|
|
53272
53306
|
/*decorators*/ undefined,
|
|
@@ -53346,8 +53380,8 @@ var ts;
|
|
|
53346
53380
|
// synthesize export * from "moduleReference"
|
|
53347
53381
|
// Straightforward - only one thing to do - make an export declaration
|
|
53348
53382
|
if (symbol.declarations) {
|
|
53349
|
-
for (var _i = 0,
|
|
53350
|
-
var node =
|
|
53383
|
+
for (var _i = 0, _e = symbol.declarations; _i < _e.length; _i++) {
|
|
53384
|
+
var node = _e[_i];
|
|
53351
53385
|
var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
|
|
53352
53386
|
if (!resolvedModule)
|
|
53353
53387
|
continue;
|
|
@@ -55153,7 +55187,10 @@ var ts;
|
|
|
55153
55187
|
if (containsSameNamedThisProperty(expression.left, expression.right)) {
|
|
55154
55188
|
return anyType;
|
|
55155
55189
|
}
|
|
55156
|
-
var
|
|
55190
|
+
var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression)));
|
|
55191
|
+
var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol)
|
|
55192
|
+
: isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right))
|
|
55193
|
+
: getWidenedLiteralType(checkExpressionCached(expression.right));
|
|
55157
55194
|
if (type.flags & 524288 /* Object */ &&
|
|
55158
55195
|
kind === 2 /* ModuleExports */ &&
|
|
55159
55196
|
symbol.escapedName === "export=" /* ExportEquals */) {
|
|
@@ -55897,7 +55934,7 @@ var ts;
|
|
|
55897
55934
|
node = paramSymbol.valueDeclaration;
|
|
55898
55935
|
}
|
|
55899
55936
|
break;
|
|
55900
|
-
case 319 /*
|
|
55937
|
+
case 319 /* JSDoc */: {
|
|
55901
55938
|
var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
|
|
55902
55939
|
return node.tags
|
|
55903
55940
|
? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; }))
|
|
@@ -58158,10 +58195,10 @@ var ts;
|
|
|
58158
58195
|
else if (type !== firstType) {
|
|
58159
58196
|
checkFlags |= 64 /* HasNonUniformType */;
|
|
58160
58197
|
}
|
|
58161
|
-
if (isLiteralType(type) || isPatternLiteralType(type)) {
|
|
58198
|
+
if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
|
|
58162
58199
|
checkFlags |= 128 /* HasLiteralType */;
|
|
58163
58200
|
}
|
|
58164
|
-
if (type.flags & 131072 /* Never */) {
|
|
58201
|
+
if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
|
|
58165
58202
|
checkFlags |= 131072 /* HasNeverType */;
|
|
58166
58203
|
}
|
|
58167
58204
|
propTypes.push(type);
|
|
@@ -59346,7 +59383,7 @@ var ts;
|
|
|
59346
59383
|
function getConditionalFlowTypeOfType(type, node) {
|
|
59347
59384
|
var constraints;
|
|
59348
59385
|
var covariant = true;
|
|
59349
|
-
while (node && !ts.isStatement(node) && node.kind !== 319 /*
|
|
59386
|
+
while (node && !ts.isStatement(node) && node.kind !== 319 /* JSDoc */) {
|
|
59350
59387
|
var parent = node.parent;
|
|
59351
59388
|
// only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but
|
|
59352
59389
|
// often get used in indexed accesses where they behave sortof invariantly, but our checking is lax
|
|
@@ -60702,10 +60739,24 @@ var ts;
|
|
|
60702
60739
|
return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
|
|
60703
60740
|
/*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
|
|
60704
60741
|
}
|
|
60742
|
+
/**
|
|
60743
|
+
* A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
|
|
60744
|
+
* must be kept generic, as that instantiation information needs to flow through the type system. By replacing all
|
|
60745
|
+
* type parameters in the union with a special never type that is treated as a literal in `getReducedType`, we can cause the `getReducedType` logic
|
|
60746
|
+
* to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
|
|
60747
|
+
*/
|
|
60748
|
+
function isPossiblyReducibleByInstantiation(type) {
|
|
60749
|
+
return ts.some(type.types, function (t) {
|
|
60750
|
+
var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
|
|
60751
|
+
return getReducedType(uniqueFilled) !== uniqueFilled;
|
|
60752
|
+
});
|
|
60753
|
+
}
|
|
60705
60754
|
function getIndexType(type, stringsOnly, noIndexSignatures) {
|
|
60706
60755
|
if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
|
|
60707
60756
|
type = getReducedType(type);
|
|
60708
|
-
return type.flags & 1048576 /* Union */ ?
|
|
60757
|
+
return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
|
|
60758
|
+
? getIndexTypeForGenericType(type, stringsOnly)
|
|
60759
|
+
: getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
60709
60760
|
type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
60710
60761
|
type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
|
|
60711
60762
|
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
|
|
@@ -61333,6 +61384,10 @@ var ts;
|
|
|
61333
61384
|
}
|
|
61334
61385
|
return type;
|
|
61335
61386
|
}
|
|
61387
|
+
function maybeCloneTypeParameter(p) {
|
|
61388
|
+
var constraint = getConstraintOfTypeParameter(p);
|
|
61389
|
+
return constraint && (isGenericObjectType(constraint) || isGenericIndexType(constraint)) ? cloneTypeParameter(p) : p;
|
|
61390
|
+
}
|
|
61336
61391
|
function isTypicalNondistributiveConditional(root) {
|
|
61337
61392
|
return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
|
|
61338
61393
|
}
|
|
@@ -61351,37 +61406,65 @@ var ts;
|
|
|
61351
61406
|
var result;
|
|
61352
61407
|
var extraTypes;
|
|
61353
61408
|
var tailCount = 0;
|
|
61354
|
-
|
|
61355
|
-
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
61356
|
-
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
61357
|
-
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
61358
|
-
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
61359
|
-
while (true) {
|
|
61409
|
+
var _loop_18 = function () {
|
|
61360
61410
|
if (tailCount === 1000) {
|
|
61361
61411
|
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
61362
61412
|
result = errorType;
|
|
61363
|
-
break;
|
|
61413
|
+
return "break";
|
|
61364
61414
|
}
|
|
61365
61415
|
var isUnwrapped = isTypicalNondistributiveConditional(root);
|
|
61366
61416
|
var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
|
|
61367
61417
|
var checkTypeInstantiable = isGenericType(checkType);
|
|
61368
61418
|
var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
|
|
61369
61419
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
61370
|
-
return wildcardType;
|
|
61420
|
+
return { value: wildcardType };
|
|
61371
61421
|
}
|
|
61372
61422
|
var combinedMapper = void 0;
|
|
61373
61423
|
if (root.inferTypeParameters) {
|
|
61374
|
-
|
|
61375
|
-
|
|
61424
|
+
// When we're looking at making an inference for an infer type, when we get its constraint, it'll automagically be
|
|
61425
|
+
// instantiated with the context, so it doesn't need the mapper for the inference contex - however the constraint
|
|
61426
|
+
// may refer to another _root_, _uncloned_ `infer` type parameter [1], or to something mapped by `mapper` [2].
|
|
61427
|
+
// [1] Eg, if we have `Foo<T, U extends T>` and `Foo<number, infer B>` - `B` is constrained to `T`, which, in turn, has been instantiated
|
|
61428
|
+
// as `number`
|
|
61429
|
+
// Conversely, if we have `Foo<infer A, infer B>`, `B` is still constrained to `T` and `T` is instantiated as `A`
|
|
61430
|
+
// [2] Eg, if we have `Foo<T, U extends T>` and `Foo<Q, infer B>` where `Q` is mapped by `mapper` into `number` - `B` is constrained to `T`
|
|
61431
|
+
// which is in turn instantiated as `Q`, which is in turn instantiated as `number`.
|
|
61432
|
+
// So we need to:
|
|
61433
|
+
// * Clone the type parameters so their constraints can be instantiated in the context of `mapper` (otherwise theyd only get inference context information)
|
|
61434
|
+
// * Set the clones to both map the conditional's enclosing `mapper` and the original params
|
|
61435
|
+
// * instantiate the extends type with the clones
|
|
61436
|
+
// * incorporate all of the component mappers into the combined mapper for the true and false members
|
|
61437
|
+
// This means we have three mappers that need applying:
|
|
61438
|
+
// * The original `mapper` used to create this conditional
|
|
61439
|
+
// * The mapper that maps the old root type parameter to the clone (`freshMapper`)
|
|
61440
|
+
// * The mapper that maps the clone to its inference result (`context.mapper`)
|
|
61441
|
+
var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
|
|
61442
|
+
var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined;
|
|
61443
|
+
var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */);
|
|
61444
|
+
if (freshMapper) {
|
|
61445
|
+
var freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
|
|
61446
|
+
for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) {
|
|
61447
|
+
var p = freshParams_1[_i];
|
|
61448
|
+
if (root.inferTypeParameters.indexOf(p) === -1) {
|
|
61449
|
+
p.mapper = freshCombinedMapper;
|
|
61450
|
+
}
|
|
61451
|
+
}
|
|
61452
|
+
}
|
|
61453
|
+
// We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
|
|
61454
|
+
// if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
|
|
61455
|
+
// "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
|
|
61456
|
+
// so in those cases we refain from performing inference and retain the uninfered type parameter
|
|
61457
|
+
if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
|
|
61376
61458
|
// We don't want inferences from constraints as they may cause us to eagerly resolve the
|
|
61377
61459
|
// conditional type instead of deferring resolution. Also, we always want strict function
|
|
61378
61460
|
// types rules (i.e. proper contravariance) for inferences.
|
|
61379
|
-
inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
61461
|
+
inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
61380
61462
|
}
|
|
61463
|
+
var innerMapper = combineTypeMappers(freshMapper, context.mapper);
|
|
61381
61464
|
// It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the
|
|
61382
61465
|
// those type parameters are used in type references (see getInferredTypeParameterConstraint). For
|
|
61383
61466
|
// that reason we need context.mapper to be first in the combined mapper. See #42636 for examples.
|
|
61384
|
-
combinedMapper = mapper ? combineTypeMappers(
|
|
61467
|
+
combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
|
|
61385
61468
|
}
|
|
61386
61469
|
// Instantiate the extends type including inferences for 'infer T' type parameters
|
|
61387
61470
|
var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType;
|
|
@@ -61403,14 +61486,14 @@ var ts;
|
|
|
61403
61486
|
var newRoot = falseType_1.root;
|
|
61404
61487
|
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
61405
61488
|
root = newRoot;
|
|
61406
|
-
continue;
|
|
61489
|
+
return "continue";
|
|
61407
61490
|
}
|
|
61408
61491
|
if (canTailRecurse(falseType_1, mapper)) {
|
|
61409
|
-
continue;
|
|
61492
|
+
return "continue";
|
|
61410
61493
|
}
|
|
61411
61494
|
}
|
|
61412
61495
|
result = instantiateType(falseType_1, mapper);
|
|
61413
|
-
break;
|
|
61496
|
+
return "break";
|
|
61414
61497
|
}
|
|
61415
61498
|
// Return trueType for a definitely true extends check. We check instantiations of the two
|
|
61416
61499
|
// types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
|
|
@@ -61421,10 +61504,10 @@ var ts;
|
|
|
61421
61504
|
var trueType_1 = getTypeFromTypeNode(root.node.trueType);
|
|
61422
61505
|
var trueMapper = combinedMapper || mapper;
|
|
61423
61506
|
if (canTailRecurse(trueType_1, trueMapper)) {
|
|
61424
|
-
continue;
|
|
61507
|
+
return "continue";
|
|
61425
61508
|
}
|
|
61426
61509
|
result = instantiateType(trueType_1, trueMapper);
|
|
61427
|
-
break;
|
|
61510
|
+
return "break";
|
|
61428
61511
|
}
|
|
61429
61512
|
}
|
|
61430
61513
|
// Return a deferred type for a check that is neither definitely true nor definitely false
|
|
@@ -61436,7 +61519,19 @@ var ts;
|
|
|
61436
61519
|
result.combinedMapper = combinedMapper;
|
|
61437
61520
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
61438
61521
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
61439
|
-
break;
|
|
61522
|
+
return "break";
|
|
61523
|
+
};
|
|
61524
|
+
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
61525
|
+
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
61526
|
+
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
61527
|
+
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
61528
|
+
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
61529
|
+
while (true) {
|
|
61530
|
+
var state_5 = _loop_18();
|
|
61531
|
+
if (typeof state_5 === "object")
|
|
61532
|
+
return state_5.value;
|
|
61533
|
+
if (state_5 === "break")
|
|
61534
|
+
break;
|
|
61440
61535
|
}
|
|
61441
61536
|
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
|
|
61442
61537
|
// We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
|
|
@@ -61858,9 +61953,11 @@ var ts;
|
|
|
61858
61953
|
}
|
|
61859
61954
|
function getESSymbolLikeTypeForNode(node) {
|
|
61860
61955
|
if (ts.isValidESSymbolDeclaration(node)) {
|
|
61861
|
-
var symbol = getSymbolOfNode(node);
|
|
61862
|
-
|
|
61863
|
-
|
|
61956
|
+
var symbol = ts.isCommonJsExportPropertyAssignment(node) ? getSymbolOfNode(node.left) : getSymbolOfNode(node);
|
|
61957
|
+
if (symbol) {
|
|
61958
|
+
var links = getSymbolLinks(symbol);
|
|
61959
|
+
return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
|
|
61960
|
+
}
|
|
61864
61961
|
}
|
|
61865
61962
|
return esSymbolType;
|
|
61866
61963
|
}
|
|
@@ -62504,6 +62601,10 @@ var ts;
|
|
|
62504
62601
|
}
|
|
62505
62602
|
return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable
|
|
62506
62603
|
}
|
|
62604
|
+
function getUniqueLiteralFilledInstantiation(type) {
|
|
62605
|
+
return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
|
|
62606
|
+
type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper));
|
|
62607
|
+
}
|
|
62507
62608
|
function getPermissiveInstantiation(type) {
|
|
62508
62609
|
return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
|
|
62509
62610
|
type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
|
|
@@ -63963,7 +64064,7 @@ var ts;
|
|
|
63963
64064
|
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
|
63964
64065
|
checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
|
|
63965
64066
|
}
|
|
63966
|
-
var
|
|
64067
|
+
var _loop_19 = function (prop) {
|
|
63967
64068
|
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
|
63968
64069
|
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
|
63969
64070
|
if (reportErrors) {
|
|
@@ -64026,9 +64127,9 @@ var ts;
|
|
|
64026
64127
|
};
|
|
64027
64128
|
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
|
|
64028
64129
|
var prop = _b[_i];
|
|
64029
|
-
var
|
|
64030
|
-
if (typeof
|
|
64031
|
-
return
|
|
64130
|
+
var state_6 = _loop_19(prop);
|
|
64131
|
+
if (typeof state_6 === "object")
|
|
64132
|
+
return state_6.value;
|
|
64032
64133
|
}
|
|
64033
64134
|
return false;
|
|
64034
64135
|
}
|
|
@@ -65018,11 +65119,11 @@ var ts;
|
|
|
65018
65119
|
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
|
65019
65120
|
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
|
65020
65121
|
var matchingTypes = [];
|
|
65021
|
-
var
|
|
65122
|
+
var _loop_20 = function (combination) {
|
|
65022
65123
|
var hasMatch = false;
|
|
65023
65124
|
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
|
|
65024
65125
|
var type = _d[_c];
|
|
65025
|
-
var
|
|
65126
|
+
var _loop_21 = function (i) {
|
|
65026
65127
|
var sourceProperty = sourcePropertiesFiltered[i];
|
|
65027
65128
|
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
|
65028
65129
|
if (!targetProperty)
|
|
@@ -65038,8 +65139,8 @@ var ts;
|
|
|
65038
65139
|
}
|
|
65039
65140
|
};
|
|
65040
65141
|
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
|
65041
|
-
var
|
|
65042
|
-
switch (
|
|
65142
|
+
var state_8 = _loop_21(i);
|
|
65143
|
+
switch (state_8) {
|
|
65043
65144
|
case "continue-outer": continue outer;
|
|
65044
65145
|
}
|
|
65045
65146
|
}
|
|
@@ -65052,9 +65153,9 @@ var ts;
|
|
|
65052
65153
|
};
|
|
65053
65154
|
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
|
65054
65155
|
var combination = discriminantCombinations_1[_a];
|
|
65055
|
-
var
|
|
65056
|
-
if (typeof
|
|
65057
|
-
return
|
|
65156
|
+
var state_7 = _loop_20(combination);
|
|
65157
|
+
if (typeof state_7 === "object")
|
|
65158
|
+
return state_7.value;
|
|
65058
65159
|
}
|
|
65059
65160
|
// Compare the remaining non-discriminant properties of each match.
|
|
65060
65161
|
var result = -1 /* True */;
|
|
@@ -65767,7 +65868,7 @@ var ts;
|
|
|
65767
65868
|
// The emptyArray singleton is used to signal a recursive invocation.
|
|
65768
65869
|
cache.variances = ts.emptyArray;
|
|
65769
65870
|
variances = [];
|
|
65770
|
-
var
|
|
65871
|
+
var _loop_22 = function (tp) {
|
|
65771
65872
|
var unmeasurable = false;
|
|
65772
65873
|
var unreliable = false;
|
|
65773
65874
|
var oldHandler = outofbandVarianceMarkerHandler;
|
|
@@ -65799,7 +65900,7 @@ var ts;
|
|
|
65799
65900
|
};
|
|
65800
65901
|
for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
|
|
65801
65902
|
var tp = typeParameters_1[_i];
|
|
65802
|
-
|
|
65903
|
+
_loop_22(tp);
|
|
65803
65904
|
}
|
|
65804
65905
|
cache.variances = variances;
|
|
65805
65906
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -68170,7 +68271,7 @@ var ts;
|
|
|
68170
68271
|
function mapTypesByKeyProperty(types, name) {
|
|
68171
68272
|
var map = new ts.Map();
|
|
68172
68273
|
var count = 0;
|
|
68173
|
-
var
|
|
68274
|
+
var _loop_23 = function (type) {
|
|
68174
68275
|
if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
|
|
68175
68276
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
68176
68277
|
if (discriminant) {
|
|
@@ -68196,9 +68297,9 @@ var ts;
|
|
|
68196
68297
|
};
|
|
68197
68298
|
for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
|
|
68198
68299
|
var type = types_16[_i];
|
|
68199
|
-
var
|
|
68200
|
-
if (typeof
|
|
68201
|
-
return
|
|
68300
|
+
var state_9 = _loop_23(type);
|
|
68301
|
+
if (typeof state_9 === "object")
|
|
68302
|
+
return state_9.value;
|
|
68202
68303
|
}
|
|
68203
68304
|
return count >= 10 && count * 2 >= types.length ? map : undefined;
|
|
68204
68305
|
}
|
|
@@ -74529,7 +74630,7 @@ var ts;
|
|
|
74529
74630
|
if (spreadIndex >= 0) {
|
|
74530
74631
|
// Create synthetic arguments from spreads of tuple types.
|
|
74531
74632
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
74532
|
-
var
|
|
74633
|
+
var _loop_24 = function (i) {
|
|
74533
74634
|
var arg = args[i];
|
|
74534
74635
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
74535
74636
|
var spreadType = arg.kind === 224 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -74546,7 +74647,7 @@ var ts;
|
|
|
74546
74647
|
}
|
|
74547
74648
|
};
|
|
74548
74649
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
74549
|
-
|
|
74650
|
+
_loop_24(i);
|
|
74550
74651
|
}
|
|
74551
74652
|
return effectiveArgs_1;
|
|
74552
74653
|
}
|
|
@@ -74859,7 +74960,7 @@ var ts;
|
|
|
74859
74960
|
var min_3 = Number.MAX_VALUE;
|
|
74860
74961
|
var minIndex = 0;
|
|
74861
74962
|
var i_1 = 0;
|
|
74862
|
-
var
|
|
74963
|
+
var _loop_25 = function (c) {
|
|
74863
74964
|
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
|
74864
74965
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
|
|
74865
74966
|
if (diags_2) {
|
|
@@ -74877,7 +74978,7 @@ var ts;
|
|
|
74877
74978
|
};
|
|
74878
74979
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
74879
74980
|
var c = candidatesForArgumentError_1[_a];
|
|
74880
|
-
|
|
74981
|
+
_loop_25(c);
|
|
74881
74982
|
}
|
|
74882
74983
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
74883
74984
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -75035,7 +75136,7 @@ var ts;
|
|
|
75035
75136
|
}
|
|
75036
75137
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
75037
75138
|
var parameters = [];
|
|
75038
|
-
var
|
|
75139
|
+
var _loop_26 = function (i) {
|
|
75039
75140
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
75040
75141
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
75041
75142
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -75043,7 +75144,7 @@ var ts;
|
|
|
75043
75144
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
75044
75145
|
};
|
|
75045
75146
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
75046
|
-
|
|
75147
|
+
_loop_26(i);
|
|
75047
75148
|
}
|
|
75048
75149
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
75049
75150
|
var flags = 0 /* None */;
|
|
@@ -78270,7 +78371,7 @@ var ts;
|
|
|
78270
78371
|
}
|
|
78271
78372
|
function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
|
|
78272
78373
|
var type = checkExpression(node, checkMode, forceTuple);
|
|
78273
|
-
return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
|
|
78374
|
+
return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
|
|
78274
78375
|
isTypeAssertion(node) ? type :
|
|
78275
78376
|
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
|
|
78276
78377
|
}
|
|
@@ -79039,7 +79140,7 @@ var ts;
|
|
|
79039
79140
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
79040
79141
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
79041
79142
|
var indexSignatureMap_1 = new ts.Map();
|
|
79042
|
-
var
|
|
79143
|
+
var _loop_27 = function (declaration) {
|
|
79043
79144
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
79044
79145
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
79045
79146
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -79054,7 +79155,7 @@ var ts;
|
|
|
79054
79155
|
};
|
|
79055
79156
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
79056
79157
|
var declaration = _a[_i];
|
|
79057
|
-
|
|
79158
|
+
_loop_27(declaration);
|
|
79058
79159
|
}
|
|
79059
79160
|
indexSignatureMap_1.forEach(function (entry) {
|
|
79060
79161
|
if (entry.declarations.length > 1) {
|
|
@@ -82433,7 +82534,7 @@ var ts;
|
|
|
82433
82534
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
|
|
82434
82535
|
var localPropDeclaration = declaration && declaration.kind === 220 /* BinaryExpression */ ||
|
|
82435
82536
|
name && name.kind === 161 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
82436
|
-
var
|
|
82537
|
+
var _loop_28 = function (info) {
|
|
82437
82538
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
82438
82539
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
82439
82540
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -82446,7 +82547,7 @@ var ts;
|
|
|
82446
82547
|
};
|
|
82447
82548
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
82448
82549
|
var info = indexInfos_9[_i];
|
|
82449
|
-
|
|
82550
|
+
_loop_28(info);
|
|
82450
82551
|
}
|
|
82451
82552
|
}
|
|
82452
82553
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -82454,7 +82555,7 @@ var ts;
|
|
|
82454
82555
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
82455
82556
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
|
|
82456
82557
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
82457
|
-
var
|
|
82558
|
+
var _loop_29 = function (info) {
|
|
82458
82559
|
if (info === checkInfo)
|
|
82459
82560
|
return "continue";
|
|
82460
82561
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -82469,7 +82570,7 @@ var ts;
|
|
|
82469
82570
|
};
|
|
82470
82571
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
82471
82572
|
var info = indexInfos_10[_i];
|
|
82472
|
-
|
|
82573
|
+
_loop_29(info);
|
|
82473
82574
|
}
|
|
82474
82575
|
}
|
|
82475
82576
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -82780,7 +82881,7 @@ var ts;
|
|
|
82780
82881
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
82781
82882
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
82782
82883
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
82783
|
-
var
|
|
82884
|
+
var _loop_30 = function (member) {
|
|
82784
82885
|
if (ts.hasAmbientModifier(member)) {
|
|
82785
82886
|
return "continue";
|
|
82786
82887
|
}
|
|
@@ -82797,7 +82898,7 @@ var ts;
|
|
|
82797
82898
|
};
|
|
82798
82899
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
82799
82900
|
var member = _a[_i];
|
|
82800
|
-
|
|
82901
|
+
_loop_30(member);
|
|
82801
82902
|
}
|
|
82802
82903
|
}
|
|
82803
82904
|
/**
|
|
@@ -82885,7 +82986,7 @@ var ts;
|
|
|
82885
82986
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
82886
82987
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
82887
82988
|
var issuedMemberError = false;
|
|
82888
|
-
var
|
|
82989
|
+
var _loop_31 = function (member) {
|
|
82889
82990
|
if (ts.isStatic(member)) {
|
|
82890
82991
|
return "continue";
|
|
82891
82992
|
}
|
|
@@ -82904,7 +83005,7 @@ var ts;
|
|
|
82904
83005
|
};
|
|
82905
83006
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
82906
83007
|
var member = _a[_i];
|
|
82907
|
-
|
|
83008
|
+
_loop_31(member);
|
|
82908
83009
|
}
|
|
82909
83010
|
if (!issuedMemberError) {
|
|
82910
83011
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -109869,7 +109970,7 @@ var ts;
|
|
|
109869
109970
|
return emitRestOrJSDocVariadicType(node);
|
|
109870
109971
|
case 318 /* JSDocNamepathType */:
|
|
109871
109972
|
return;
|
|
109872
|
-
case 319 /*
|
|
109973
|
+
case 319 /* JSDoc */:
|
|
109873
109974
|
return emitJSDoc(node);
|
|
109874
109975
|
case 321 /* JSDocTypeLiteral */:
|
|
109875
109976
|
return emitJSDocTypeLiteral(node);
|
|
@@ -120691,7 +120792,7 @@ var ts;
|
|
|
120691
120792
|
});
|
|
120692
120793
|
// Sort by paths closest to importing file Name directory
|
|
120693
120794
|
var sortedPaths = [];
|
|
120694
|
-
var
|
|
120795
|
+
var _loop_32 = function (directory) {
|
|
120695
120796
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
120696
120797
|
var pathsInDirectory;
|
|
120697
120798
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -120715,9 +120816,9 @@ var ts;
|
|
|
120715
120816
|
};
|
|
120716
120817
|
var out_directory_1;
|
|
120717
120818
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
120718
|
-
var
|
|
120819
|
+
var state_10 = _loop_32(directory);
|
|
120719
120820
|
directory = out_directory_1;
|
|
120720
|
-
if (
|
|
120821
|
+
if (state_10 === "break")
|
|
120721
120822
|
break;
|
|
120722
120823
|
}
|
|
120723
120824
|
if (allFileNames.size) {
|