typescript 4.5.0-dev.20210923 → 4.5.0-dev.20210924
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/lib.es2021.d.ts +1 -0
- package/lib/lib.es2021.intl.d.ts +9 -0
- package/lib/tsc.js +116 -60
- package/lib/tsserver.js +133 -70
- package/lib/tsserverlibrary.js +133 -70
- package/lib/typescript.js +133 -70
- package/lib/typescriptServices.js +133 -70
- package/lib/typingsInstaller.js +122 -62
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20210924";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -4928,6 +4928,7 @@ var ts;
|
|
|
4928
4928
|
CheckFlags[CheckFlags["HasNeverType"] = 131072] = "HasNeverType";
|
|
4929
4929
|
CheckFlags[CheckFlags["Mapped"] = 262144] = "Mapped";
|
|
4930
4930
|
CheckFlags[CheckFlags["StripOptional"] = 524288] = "StripOptional";
|
|
4931
|
+
CheckFlags[CheckFlags["Unresolved"] = 1048576] = "Unresolved";
|
|
4931
4932
|
CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic";
|
|
4932
4933
|
CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant";
|
|
4933
4934
|
CheckFlags[CheckFlags["Partial"] = 48] = "Partial";
|
|
@@ -46629,10 +46630,13 @@ var ts;
|
|
|
46629
46630
|
var undefinedProperties = new ts.Map();
|
|
46630
46631
|
var unknownSymbol = createSymbol(4 /* Property */, "unknown");
|
|
46631
46632
|
var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */);
|
|
46633
|
+
var unresolvedSymbols = new ts.Map();
|
|
46634
|
+
var errorTypes = new ts.Map();
|
|
46632
46635
|
var anyType = createIntrinsicType(1 /* Any */, "any");
|
|
46633
46636
|
var autoType = createIntrinsicType(1 /* Any */, "any");
|
|
46634
46637
|
var wildcardType = createIntrinsicType(1 /* Any */, "any");
|
|
46635
46638
|
var errorType = createIntrinsicType(1 /* Any */, "error");
|
|
46639
|
+
var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
|
|
46636
46640
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */);
|
|
46637
46641
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
46638
46642
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
@@ -50071,7 +50075,9 @@ var ts;
|
|
|
50071
50075
|
var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer);
|
|
50072
50076
|
if (typeNode === undefined)
|
|
50073
50077
|
return ts.Debug.fail("should always get typenode");
|
|
50074
|
-
|
|
50078
|
+
// The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`.
|
|
50079
|
+
// Otherwise, we always strip comments out.
|
|
50080
|
+
var options = { removeComments: type !== unresolvedType };
|
|
50075
50081
|
var printer = ts.createPrinter(options);
|
|
50076
50082
|
var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
|
|
50077
50083
|
printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer);
|
|
@@ -50216,6 +50222,12 @@ var ts;
|
|
|
50216
50222
|
type = getReducedType(type);
|
|
50217
50223
|
}
|
|
50218
50224
|
if (type.flags & 1 /* Any */) {
|
|
50225
|
+
if (type.aliasSymbol) {
|
|
50226
|
+
return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context));
|
|
50227
|
+
}
|
|
50228
|
+
if (type === unresolvedType) {
|
|
50229
|
+
return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved");
|
|
50230
|
+
}
|
|
50219
50231
|
context.approximateLength += 3;
|
|
50220
50232
|
return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */);
|
|
50221
50233
|
}
|
|
@@ -51304,6 +51316,10 @@ var ts;
|
|
|
51304
51316
|
}
|
|
51305
51317
|
return specifier;
|
|
51306
51318
|
}
|
|
51319
|
+
function symbolToEntityNameNode(symbol) {
|
|
51320
|
+
var identifier = ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(symbol.escapedName));
|
|
51321
|
+
return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
|
|
51322
|
+
}
|
|
51307
51323
|
function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
|
|
51308
51324
|
var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
|
|
51309
51325
|
var isTypeOf = meaning === 111551 /* Value */;
|
|
@@ -51590,7 +51606,7 @@ var ts;
|
|
|
51590
51606
|
* so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym`
|
|
51591
51607
|
*/
|
|
51592
51608
|
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
|
|
51593
|
-
if (type
|
|
51609
|
+
if (!isErrorType(type) && enclosingDeclaration) {
|
|
51594
51610
|
var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
|
|
51595
51611
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
51596
51612
|
// try to reuse the existing annotation
|
|
@@ -51613,7 +51629,7 @@ var ts;
|
|
|
51613
51629
|
return result;
|
|
51614
51630
|
}
|
|
51615
51631
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
51616
|
-
if (type
|
|
51632
|
+
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
51617
51633
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
51618
51634
|
if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) {
|
|
51619
51635
|
var annotated = getTypeFromTypeNode(annotation);
|
|
@@ -51720,7 +51736,7 @@ var ts;
|
|
|
51720
51736
|
/*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
|
|
51721
51737
|
}
|
|
51722
51738
|
}
|
|
51723
|
-
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(
|
|
51739
|
+
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) {
|
|
51724
51740
|
return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
|
|
51725
51741
|
}
|
|
51726
51742
|
if (ts.isLiteralImportTypeNode(node)) {
|
|
@@ -53348,6 +53364,11 @@ var ts;
|
|
|
53348
53364
|
function isTypeAny(type) {
|
|
53349
53365
|
return type && (type.flags & 1 /* Any */) !== 0;
|
|
53350
53366
|
}
|
|
53367
|
+
function isErrorType(type) {
|
|
53368
|
+
// The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for
|
|
53369
|
+
// a reference to an unresolved symbol. We want those to behave like the errorType.
|
|
53370
|
+
return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol);
|
|
53371
|
+
}
|
|
53351
53372
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
53352
53373
|
// assigned by contextual typing.
|
|
53353
53374
|
function getTypeForBindingElementParent(node) {
|
|
@@ -53865,7 +53886,7 @@ var ts;
|
|
|
53865
53886
|
if (!declaredType) {
|
|
53866
53887
|
return type;
|
|
53867
53888
|
}
|
|
53868
|
-
else if (declaredType
|
|
53889
|
+
else if (!isErrorType(declaredType) && !isErrorType(type) && !isTypeIdenticalTo(declaredType, type)) {
|
|
53869
53890
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
|
|
53870
53891
|
}
|
|
53871
53892
|
}
|
|
@@ -54759,7 +54780,7 @@ var ts;
|
|
|
54759
54780
|
for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
|
|
54760
54781
|
var node = implementsTypeNodes_1[_b];
|
|
54761
54782
|
var implementsType = getTypeFromTypeNode(node);
|
|
54762
|
-
if (implementsType
|
|
54783
|
+
if (!isErrorType(implementsType)) {
|
|
54763
54784
|
if (resolvedImplementsTypes === ts.emptyArray) {
|
|
54764
54785
|
resolvedImplementsTypes = [implementsType];
|
|
54765
54786
|
}
|
|
@@ -54839,7 +54860,7 @@ var ts;
|
|
|
54839
54860
|
}
|
|
54840
54861
|
baseType = getReturnTypeOfSignature(constructors[0]);
|
|
54841
54862
|
}
|
|
54842
|
-
if (baseType
|
|
54863
|
+
if (isErrorType(baseType)) {
|
|
54843
54864
|
return type.resolvedBaseTypes = ts.emptyArray;
|
|
54844
54865
|
}
|
|
54845
54866
|
var reducedBaseType = getReducedType(baseType);
|
|
@@ -54895,7 +54916,7 @@ var ts;
|
|
|
54895
54916
|
for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
|
|
54896
54917
|
var node = _c[_b];
|
|
54897
54918
|
var baseType = getReducedType(getTypeFromTypeNode(node));
|
|
54898
|
-
if (baseType
|
|
54919
|
+
if (!isErrorType(baseType)) {
|
|
54899
54920
|
if (isValidBaseType(baseType)) {
|
|
54900
54921
|
if (type !== baseType && !hasBaseType(baseType, type)) {
|
|
54901
54922
|
if (type.resolvedBaseTypes === ts.emptyArray) {
|
|
@@ -56737,7 +56758,7 @@ var ts;
|
|
|
56737
56758
|
for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) {
|
|
56738
56759
|
var current = _c[_i];
|
|
56739
56760
|
var type = getApparentType(current);
|
|
56740
|
-
if (!(type
|
|
56761
|
+
if (!(isErrorType(type) || type.flags & 131072 /* Never */)) {
|
|
56741
56762
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
56742
56763
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
56743
56764
|
if (prop) {
|
|
@@ -57687,7 +57708,7 @@ var ts;
|
|
|
57687
57708
|
}
|
|
57688
57709
|
else {
|
|
57689
57710
|
var type = getTypeFromTypeNode(constraintDeclaration);
|
|
57690
|
-
if (type.flags & 1 /* Any */ && type
|
|
57711
|
+
if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed
|
|
57691
57712
|
// use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was),
|
|
57692
57713
|
// use unknown otherwise
|
|
57693
57714
|
type = constraintDeclaration.parent.parent.kind === 194 /* MappedType */ ? keyofConstraintType : unknownType;
|
|
@@ -57859,6 +57880,18 @@ var ts;
|
|
|
57859
57880
|
* declared type. Instantiations are cached using the type identities of the type arguments as the key.
|
|
57860
57881
|
*/
|
|
57861
57882
|
function getTypeFromTypeAliasReference(node, symbol) {
|
|
57883
|
+
if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) {
|
|
57884
|
+
var typeArguments = typeArgumentsFromTypeReferenceNode(node);
|
|
57885
|
+
var id = getAliasId(symbol, typeArguments);
|
|
57886
|
+
var errorType_1 = errorTypes.get(id);
|
|
57887
|
+
if (!errorType_1) {
|
|
57888
|
+
errorType_1 = createIntrinsicType(1 /* Any */, "error");
|
|
57889
|
+
errorType_1.aliasSymbol = symbol;
|
|
57890
|
+
errorType_1.aliasTypeArguments = typeArguments;
|
|
57891
|
+
errorTypes.set(id, errorType_1);
|
|
57892
|
+
}
|
|
57893
|
+
return errorType_1;
|
|
57894
|
+
}
|
|
57862
57895
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
57863
57896
|
var typeParameters = getSymbolLinks(symbol).typeParameters;
|
|
57864
57897
|
if (typeParameters) {
|
|
@@ -57900,11 +57933,37 @@ var ts;
|
|
|
57900
57933
|
}
|
|
57901
57934
|
return undefined;
|
|
57902
57935
|
}
|
|
57903
|
-
function
|
|
57904
|
-
|
|
57936
|
+
function getSymbolPath(symbol) {
|
|
57937
|
+
return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName;
|
|
57938
|
+
}
|
|
57939
|
+
function getUnresolvedSymbolForEntityName(name) {
|
|
57940
|
+
var identifier = name.kind === 160 /* QualifiedName */ ? name.right :
|
|
57941
|
+
name.kind === 205 /* PropertyAccessExpression */ ? name.name :
|
|
57942
|
+
name;
|
|
57943
|
+
var text = identifier.escapedText;
|
|
57944
|
+
if (text) {
|
|
57945
|
+
var parentSymbol = name.kind === 160 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) :
|
|
57946
|
+
name.kind === 205 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) :
|
|
57947
|
+
undefined;
|
|
57948
|
+
var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text;
|
|
57949
|
+
var result = unresolvedSymbols.get(path);
|
|
57950
|
+
if (!result) {
|
|
57951
|
+
unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */));
|
|
57952
|
+
result.parent = parentSymbol;
|
|
57953
|
+
result.declaredType = unresolvedType;
|
|
57954
|
+
}
|
|
57955
|
+
return result;
|
|
57956
|
+
}
|
|
57957
|
+
return unknownSymbol;
|
|
57958
|
+
}
|
|
57959
|
+
function resolveTypeReferenceName(typeReference, meaning, ignoreErrors) {
|
|
57960
|
+
var name = getTypeReferenceName(typeReference);
|
|
57961
|
+
if (!name) {
|
|
57905
57962
|
return unknownSymbol;
|
|
57906
57963
|
}
|
|
57907
|
-
|
|
57964
|
+
var symbol = resolveEntityName(name, meaning, ignoreErrors);
|
|
57965
|
+
return symbol && symbol !== unknownSymbol ? symbol :
|
|
57966
|
+
ignoreErrors ? unknownSymbol : getUnresolvedSymbolForEntityName(name);
|
|
57908
57967
|
}
|
|
57909
57968
|
function getTypeReferenceType(node, symbol) {
|
|
57910
57969
|
if (symbol === unknownSymbol) {
|
|
@@ -57929,7 +57988,7 @@ var ts;
|
|
|
57929
57988
|
}
|
|
57930
57989
|
else {
|
|
57931
57990
|
// Resolve the type reference as a Type for the purpose of reporting errors.
|
|
57932
|
-
resolveTypeReferenceName(
|
|
57991
|
+
resolveTypeReferenceName(node, 788968 /* Type */);
|
|
57933
57992
|
return getTypeOfSymbol(symbol);
|
|
57934
57993
|
}
|
|
57935
57994
|
}
|
|
@@ -58073,18 +58132,18 @@ var ts;
|
|
|
58073
58132
|
if (isJSDocTypeReference(node)) {
|
|
58074
58133
|
type = getIntendedTypeFromJSDocTypeReference(node);
|
|
58075
58134
|
if (!type) {
|
|
58076
|
-
symbol = resolveTypeReferenceName(
|
|
58135
|
+
symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true);
|
|
58077
58136
|
if (symbol === unknownSymbol) {
|
|
58078
|
-
symbol = resolveTypeReferenceName(
|
|
58137
|
+
symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */);
|
|
58079
58138
|
}
|
|
58080
58139
|
else {
|
|
58081
|
-
resolveTypeReferenceName(
|
|
58140
|
+
resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
|
|
58082
58141
|
}
|
|
58083
58142
|
type = getTypeReferenceType(node, symbol);
|
|
58084
58143
|
}
|
|
58085
58144
|
}
|
|
58086
58145
|
if (!type) {
|
|
58087
|
-
symbol = resolveTypeReferenceName(
|
|
58146
|
+
symbol = resolveTypeReferenceName(node, meaning);
|
|
58088
58147
|
type = getTypeReferenceType(node, symbol);
|
|
58089
58148
|
}
|
|
58090
58149
|
// Cache both the resolved symbol and the resolved type. The resolved symbol is needed when we check the
|
|
@@ -58345,7 +58404,7 @@ var ts;
|
|
|
58345
58404
|
function mayResolveTypeAlias(node) {
|
|
58346
58405
|
switch (node.kind) {
|
|
58347
58406
|
case 177 /* TypeReference */:
|
|
58348
|
-
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node
|
|
58407
|
+
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */);
|
|
58349
58408
|
case 180 /* TypeQuery */:
|
|
58350
58409
|
return true;
|
|
58351
58410
|
case 192 /* TypeOperator */:
|
|
@@ -60874,7 +60933,7 @@ var ts;
|
|
|
60874
60933
|
var mappedTypeVariable = instantiateType(typeVariable, mapper);
|
|
60875
60934
|
if (typeVariable !== mappedTypeVariable) {
|
|
60876
60935
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
60877
|
-
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t
|
|
60936
|
+
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
60878
60937
|
if (!type.declaration.nameType) {
|
|
60879
60938
|
if (isArrayType(t)) {
|
|
60880
60939
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
@@ -60916,7 +60975,7 @@ var ts;
|
|
|
60916
60975
|
}
|
|
60917
60976
|
function instantiateMappedArrayType(arrayType, mappedType, mapper) {
|
|
60918
60977
|
var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper);
|
|
60919
|
-
return elementType
|
|
60978
|
+
return isErrorType(elementType) ? errorType :
|
|
60920
60979
|
createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
|
|
60921
60980
|
}
|
|
60922
60981
|
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
@@ -62498,7 +62557,7 @@ var ts;
|
|
|
62498
62557
|
var targetTypes = target.types;
|
|
62499
62558
|
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
62500
62559
|
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
62501
|
-
if (intrinsicAttributes
|
|
62560
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
62502
62561
|
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
62503
62562
|
// do not report top error
|
|
62504
62563
|
return result;
|
|
@@ -69475,8 +69534,7 @@ var ts;
|
|
|
69475
69534
|
if (result) {
|
|
69476
69535
|
return result;
|
|
69477
69536
|
}
|
|
69478
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) {
|
|
69479
|
-
// This is less a contextual type and more an implied shape - in some cases, this may be undesirable
|
|
69537
|
+
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
|
|
69480
69538
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
69481
69539
|
}
|
|
69482
69540
|
}
|
|
@@ -70057,7 +70115,7 @@ var ts;
|
|
|
70057
70115
|
var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
|
|
70058
70116
|
propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
|
|
70059
70117
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
70060
|
-
if (intrinsicAttribs
|
|
70118
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
70061
70119
|
propsType = intersectTypes(intrinsicAttribs, propsType);
|
|
70062
70120
|
}
|
|
70063
70121
|
return propsType;
|
|
@@ -70150,7 +70208,7 @@ var ts;
|
|
|
70150
70208
|
// Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
|
|
70151
70209
|
var apparentAttributesType = attributesType;
|
|
70152
70210
|
var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
|
|
70153
|
-
if (intrinsicClassAttribs
|
|
70211
|
+
if (!isErrorType(intrinsicClassAttribs)) {
|
|
70154
70212
|
var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
|
|
70155
70213
|
var hostClassType = getReturnTypeOfSignature(sig);
|
|
70156
70214
|
apparentAttributesType = intersectTypes(typeParams
|
|
@@ -70158,7 +70216,7 @@ var ts;
|
|
|
70158
70216
|
: intrinsicClassAttribs, apparentAttributesType);
|
|
70159
70217
|
}
|
|
70160
70218
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
70161
|
-
if (intrinsicAttribs
|
|
70219
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
70162
70220
|
apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
|
|
70163
70221
|
}
|
|
70164
70222
|
return apparentAttributesType;
|
|
@@ -70626,7 +70684,7 @@ var ts;
|
|
|
70626
70684
|
checkSpreadPropOverrides(mergedType, allPropertiesTable, memberDecl);
|
|
70627
70685
|
}
|
|
70628
70686
|
offset = propertiesArray.length;
|
|
70629
|
-
if (spread
|
|
70687
|
+
if (isErrorType(spread)) {
|
|
70630
70688
|
continue;
|
|
70631
70689
|
}
|
|
70632
70690
|
spread = getSpreadType(spread, mergedType, node.symbol, objectFlags, inConstContext);
|
|
@@ -70683,7 +70741,7 @@ var ts;
|
|
|
70683
70741
|
}
|
|
70684
70742
|
}
|
|
70685
70743
|
}
|
|
70686
|
-
if (spread
|
|
70744
|
+
if (isErrorType(spread)) {
|
|
70687
70745
|
return errorType;
|
|
70688
70746
|
}
|
|
70689
70747
|
if (spread !== emptyObjectType) {
|
|
@@ -70950,7 +71008,7 @@ var ts;
|
|
|
70950
71008
|
var links = getNodeLinks(node);
|
|
70951
71009
|
if (!links.resolvedSymbol) {
|
|
70952
71010
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
|
|
70953
|
-
if (intrinsicElementsType
|
|
71011
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
70954
71012
|
// Property case
|
|
70955
71013
|
if (!ts.isIdentifier(node.tagName))
|
|
70956
71014
|
return ts.Debug.fail();
|
|
@@ -71113,7 +71171,7 @@ var ts;
|
|
|
71113
71171
|
// var CustomTag: "h1" = "h1";
|
|
71114
71172
|
// <CustomTag> Hello World </CustomTag>
|
|
71115
71173
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
|
|
71116
|
-
if (intrinsicElementsType
|
|
71174
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
71117
71175
|
var stringLiteralTypeName = type.value;
|
|
71118
71176
|
var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
|
|
71119
71177
|
if (intrinsicProp) {
|
|
@@ -71181,7 +71239,7 @@ var ts;
|
|
|
71181
71239
|
}
|
|
71182
71240
|
function getJsxElementClassTypeAt(location) {
|
|
71183
71241
|
var type = getJsxType(JsxNames.ElementClass, location);
|
|
71184
|
-
if (type
|
|
71242
|
+
if (isErrorType(type))
|
|
71185
71243
|
return undefined;
|
|
71186
71244
|
return type;
|
|
71187
71245
|
}
|
|
@@ -71487,7 +71545,7 @@ var ts;
|
|
|
71487
71545
|
}
|
|
71488
71546
|
function checkNonNullNonVoidType(type, node) {
|
|
71489
71547
|
var nonNullType = checkNonNullType(type, node);
|
|
71490
|
-
if (nonNullType
|
|
71548
|
+
if (nonNullType.flags & 16384 /* Void */) {
|
|
71491
71549
|
error(node, ts.Diagnostics.Object_is_possibly_undefined);
|
|
71492
71550
|
}
|
|
71493
71551
|
return nonNullType;
|
|
@@ -71604,7 +71662,7 @@ var ts;
|
|
|
71604
71662
|
}
|
|
71605
71663
|
if (isAnyLike) {
|
|
71606
71664
|
if (lexicallyScopedSymbol) {
|
|
71607
|
-
return apparentType;
|
|
71665
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
71608
71666
|
}
|
|
71609
71667
|
if (!ts.getContainingClass(right)) {
|
|
71610
71668
|
grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
@@ -71628,7 +71686,8 @@ var ts;
|
|
|
71628
71686
|
if (ts.isIdentifier(left) && parentSymbol) {
|
|
71629
71687
|
markAliasReferenced(parentSymbol, node);
|
|
71630
71688
|
}
|
|
71631
|
-
return apparentType;
|
|
71689
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
71690
|
+
;
|
|
71632
71691
|
}
|
|
71633
71692
|
prop = getPropertyOfType(apparentType, right.escapedText);
|
|
71634
71693
|
}
|
|
@@ -72087,7 +72146,7 @@ var ts;
|
|
|
72087
72146
|
}
|
|
72088
72147
|
function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
|
|
72089
72148
|
// Short-circuiting for improved performance.
|
|
72090
|
-
if (
|
|
72149
|
+
if (isTypeAny(type)) {
|
|
72091
72150
|
return true;
|
|
72092
72151
|
}
|
|
72093
72152
|
var prop = getPropertyOfType(type, propertyName);
|
|
@@ -72105,7 +72164,7 @@ var ts;
|
|
|
72105
72164
|
*/
|
|
72106
72165
|
function isPropertyAccessible(node, isSuper, isWrite, containingType, property) {
|
|
72107
72166
|
// Short-circuiting for improved performance.
|
|
72108
|
-
if (
|
|
72167
|
+
if (isTypeAny(containingType)) {
|
|
72109
72168
|
return true;
|
|
72110
72169
|
}
|
|
72111
72170
|
// A #private property access in an optional chain is an error dealt with by the parser.
|
|
@@ -72176,7 +72235,7 @@ var ts;
|
|
|
72176
72235
|
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
|
|
72177
72236
|
var indexExpression = node.argumentExpression;
|
|
72178
72237
|
var indexType = checkExpression(indexExpression);
|
|
72179
|
-
if (objectType
|
|
72238
|
+
if (isErrorType(objectType) || objectType === silentNeverType) {
|
|
72180
72239
|
return objectType;
|
|
72181
72240
|
}
|
|
72182
72241
|
if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
|
|
@@ -72421,7 +72480,7 @@ var ts;
|
|
|
72421
72480
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
72422
72481
|
// return type of 'wrap'.
|
|
72423
72482
|
if (node.kind !== 164 /* Decorator */) {
|
|
72424
|
-
var contextualType = getContextualType(node, 8 /* SkipBindingPatterns */);
|
|
72483
|
+
var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
72425
72484
|
if (contextualType) {
|
|
72426
72485
|
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
72427
72486
|
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
@@ -73370,7 +73429,7 @@ var ts;
|
|
|
73370
73429
|
}
|
|
73371
73430
|
return anySignature;
|
|
73372
73431
|
}
|
|
73373
|
-
if (superType
|
|
73432
|
+
if (!isErrorType(superType)) {
|
|
73374
73433
|
// In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated
|
|
73375
73434
|
// with the type arguments specified in the extends clause.
|
|
73376
73435
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
|
|
@@ -73398,7 +73457,7 @@ var ts;
|
|
|
73398
73457
|
return silentNeverSignature;
|
|
73399
73458
|
}
|
|
73400
73459
|
var apparentType = getApparentType(funcType);
|
|
73401
|
-
if (apparentType
|
|
73460
|
+
if (isErrorType(apparentType)) {
|
|
73402
73461
|
// Another error has already been reported
|
|
73403
73462
|
return resolveErrorCall(node);
|
|
73404
73463
|
}
|
|
@@ -73414,7 +73473,7 @@ var ts;
|
|
|
73414
73473
|
if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
|
|
73415
73474
|
// The unknownType indicates that an error already occurred (and was reported). No
|
|
73416
73475
|
// need to report another error in this case.
|
|
73417
|
-
if (funcType
|
|
73476
|
+
if (!isErrorType(funcType) && node.typeArguments) {
|
|
73418
73477
|
error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
|
73419
73478
|
}
|
|
73420
73479
|
return resolveUntypedCall(node);
|
|
@@ -73491,7 +73550,7 @@ var ts;
|
|
|
73491
73550
|
// signatures for overload resolution. The result type of the function call becomes
|
|
73492
73551
|
// the result type of the operation.
|
|
73493
73552
|
expressionType = getApparentType(expressionType);
|
|
73494
|
-
if (expressionType
|
|
73553
|
+
if (isErrorType(expressionType)) {
|
|
73495
73554
|
// Another error has already been reported
|
|
73496
73555
|
return resolveErrorCall(node);
|
|
73497
73556
|
}
|
|
@@ -73706,7 +73765,7 @@ var ts;
|
|
|
73706
73765
|
function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
|
|
73707
73766
|
var tagType = checkExpression(node.tag);
|
|
73708
73767
|
var apparentType = getApparentType(tagType);
|
|
73709
|
-
if (apparentType
|
|
73768
|
+
if (isErrorType(apparentType)) {
|
|
73710
73769
|
// Another error has already been reported
|
|
73711
73770
|
return resolveErrorCall(node);
|
|
73712
73771
|
}
|
|
@@ -73752,7 +73811,7 @@ var ts;
|
|
|
73752
73811
|
function resolveDecorator(node, candidatesOutArray, checkMode) {
|
|
73753
73812
|
var funcType = checkExpression(node.expression);
|
|
73754
73813
|
var apparentType = getApparentType(funcType);
|
|
73755
|
-
if (apparentType
|
|
73814
|
+
if (isErrorType(apparentType)) {
|
|
73756
73815
|
return resolveErrorCall(node);
|
|
73757
73816
|
}
|
|
73758
73817
|
var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
|
|
@@ -73807,7 +73866,7 @@ var ts;
|
|
|
73807
73866
|
}
|
|
73808
73867
|
var exprTypes = checkExpression(node.tagName);
|
|
73809
73868
|
var apparentType = getApparentType(exprTypes);
|
|
73810
|
-
if (apparentType
|
|
73869
|
+
if (isErrorType(apparentType)) {
|
|
73811
73870
|
return resolveErrorCall(node);
|
|
73812
73871
|
}
|
|
73813
73872
|
var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
|
|
@@ -74130,7 +74189,7 @@ var ts;
|
|
|
74130
74189
|
}
|
|
74131
74190
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
|
|
74132
74191
|
var _a;
|
|
74133
|
-
if (allowSyntheticDefaultImports && type && type
|
|
74192
|
+
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
74134
74193
|
var synthType = type;
|
|
74135
74194
|
if (!synthType.syntheticType) {
|
|
74136
74195
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
@@ -74236,7 +74295,7 @@ var ts;
|
|
|
74236
74295
|
checkSourceElement(type);
|
|
74237
74296
|
exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
|
|
74238
74297
|
var targetType = getTypeFromTypeNode(type);
|
|
74239
|
-
if (produceDiagnostics && targetType
|
|
74298
|
+
if (produceDiagnostics && !isErrorType(targetType)) {
|
|
74240
74299
|
var widenedType = getWidenedType(exprType);
|
|
74241
74300
|
if (!isTypeComparableTo(targetType, widenedType)) {
|
|
74242
74301
|
checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
|
|
@@ -74269,7 +74328,7 @@ var ts;
|
|
|
74269
74328
|
return getGlobalImportMetaExpressionType();
|
|
74270
74329
|
case 103 /* NewKeyword */:
|
|
74271
74330
|
var type = checkNewTargetMetaProperty(node);
|
|
74272
|
-
return type
|
|
74331
|
+
return isErrorType(type) ? errorType : createNewTargetExpressionType(type);
|
|
74273
74332
|
default:
|
|
74274
74333
|
ts.Debug.assertNever(node.keywordToken);
|
|
74275
74334
|
}
|
|
@@ -75262,7 +75321,7 @@ var ts;
|
|
|
75262
75321
|
}
|
|
75263
75322
|
var operandType = checkExpression(node.expression);
|
|
75264
75323
|
var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
75265
|
-
if (awaitedType === operandType && awaitedType
|
|
75324
|
+
if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
|
|
75266
75325
|
addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
|
|
75267
75326
|
}
|
|
75268
75327
|
return awaitedType;
|
|
@@ -75903,7 +75962,7 @@ var ts;
|
|
|
75903
75962
|
else if (isTypeAny(leftType) || isTypeAny(rightType)) {
|
|
75904
75963
|
// Otherwise, the result is of type Any.
|
|
75905
75964
|
// NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
|
|
75906
|
-
resultType = leftType
|
|
75965
|
+
resultType = isErrorType(leftType) || isErrorType(rightType) ? errorType : anyType;
|
|
75907
75966
|
}
|
|
75908
75967
|
// Symbols are not allowed at all in arithmetic expressions
|
|
75909
75968
|
if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
|
|
@@ -77381,7 +77440,7 @@ var ts;
|
|
|
77381
77440
|
}
|
|
77382
77441
|
function getTypeParametersForTypeReference(node) {
|
|
77383
77442
|
var type = getTypeFromTypeReference(node);
|
|
77384
|
-
if (type
|
|
77443
|
+
if (!isErrorType(type)) {
|
|
77385
77444
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
77386
77445
|
if (symbol) {
|
|
77387
77446
|
return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters ||
|
|
@@ -77397,7 +77456,7 @@ var ts;
|
|
|
77397
77456
|
}
|
|
77398
77457
|
ts.forEach(node.typeArguments, checkSourceElement);
|
|
77399
77458
|
var type = getTypeFromTypeReference(node);
|
|
77400
|
-
if (type
|
|
77459
|
+
if (!isErrorType(type)) {
|
|
77401
77460
|
if (node.typeArguments && produceDiagnostics) {
|
|
77402
77461
|
var typeParameters = getTypeParametersForTypeReference(node);
|
|
77403
77462
|
if (typeParameters) {
|
|
@@ -78223,7 +78282,7 @@ var ts;
|
|
|
78223
78282
|
//
|
|
78224
78283
|
var returnType = getTypeFromTypeNode(returnTypeNode);
|
|
78225
78284
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
78226
|
-
if (returnType
|
|
78285
|
+
if (isErrorType(returnType)) {
|
|
78227
78286
|
return;
|
|
78228
78287
|
}
|
|
78229
78288
|
var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true);
|
|
@@ -78237,7 +78296,7 @@ var ts;
|
|
|
78237
78296
|
else {
|
|
78238
78297
|
// Always mark the type node as referenced if it points to a value
|
|
78239
78298
|
markTypeNodeAsReferenced(returnTypeNode);
|
|
78240
|
-
if (returnType
|
|
78299
|
+
if (isErrorType(returnType)) {
|
|
78241
78300
|
return;
|
|
78242
78301
|
}
|
|
78243
78302
|
var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
|
|
@@ -78247,7 +78306,7 @@ var ts;
|
|
|
78247
78306
|
}
|
|
78248
78307
|
var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true);
|
|
78249
78308
|
var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
|
|
78250
|
-
if (promiseConstructorType
|
|
78309
|
+
if (isErrorType(promiseConstructorType)) {
|
|
78251
78310
|
if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) {
|
|
78252
78311
|
error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
78253
78312
|
}
|
|
@@ -79299,7 +79358,7 @@ var ts;
|
|
|
79299
79358
|
// Node is a secondary declaration, check that type is identical to primary declaration and check that
|
|
79300
79359
|
// initializer is consistent with type associated with the node
|
|
79301
79360
|
var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
|
|
79302
|
-
if (type
|
|
79361
|
+
if (!isErrorType(type) && !isErrorType(declarationType) &&
|
|
79303
79362
|
!isTypeIdenticalTo(type, declarationType) &&
|
|
79304
79363
|
!(symbol.flags & 67108864 /* Assignment */)) {
|
|
79305
79364
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
|
|
@@ -80797,7 +80856,7 @@ var ts;
|
|
|
80797
80856
|
checkTypeReferenceNode(typeRefNode);
|
|
80798
80857
|
if (produceDiagnostics) {
|
|
80799
80858
|
var t = getReducedType(getTypeFromTypeNode(typeRefNode));
|
|
80800
|
-
if (t
|
|
80859
|
+
if (!isErrorType(t)) {
|
|
80801
80860
|
if (isValidBaseType(t)) {
|
|
80802
80861
|
var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
|
|
80803
80862
|
ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
|
|
@@ -82837,7 +82896,8 @@ var ts;
|
|
|
82837
82896
|
}
|
|
82838
82897
|
else if (isTypeReferenceIdentifier(name)) {
|
|
82839
82898
|
var meaning = name.parent.kind === 177 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */;
|
|
82840
|
-
|
|
82899
|
+
var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
|
|
82900
|
+
return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name);
|
|
82841
82901
|
}
|
|
82842
82902
|
if (name.parent.kind === 176 /* TypePredicate */) {
|
|
82843
82903
|
return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */);
|
|
@@ -83064,7 +83124,7 @@ var ts;
|
|
|
83064
83124
|
var symbol = getSymbolAtLocation(node);
|
|
83065
83125
|
if (symbol) {
|
|
83066
83126
|
var declaredType = getDeclaredTypeOfSymbol(symbol);
|
|
83067
|
-
return declaredType
|
|
83127
|
+
return !isErrorType(declaredType) ? declaredType : getTypeOfSymbol(symbol);
|
|
83068
83128
|
}
|
|
83069
83129
|
}
|
|
83070
83130
|
if (ts.isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
@@ -83562,7 +83622,7 @@ var ts;
|
|
|
83562
83622
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83563
83623
|
}
|
|
83564
83624
|
var type = getDeclaredTypeOfSymbol(typeSymbol);
|
|
83565
|
-
if (type
|
|
83625
|
+
if (isErrorType(type)) {
|
|
83566
83626
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83567
83627
|
}
|
|
83568
83628
|
else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
@@ -127363,7 +127423,7 @@ var ts;
|
|
|
127363
127423
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
127364
127424
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
127365
127425
|
}
|
|
127366
|
-
function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) {
|
|
127426
|
+
function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, isTypeOnlyImport, useSemicolons, options, preferences) {
|
|
127367
127427
|
var _a;
|
|
127368
127428
|
var insertText;
|
|
127369
127429
|
var replacementSpan = ts.getReplacementSpanForContextToken(contextToken);
|
|
@@ -127417,7 +127477,7 @@ var ts;
|
|
|
127417
127477
|
if (originIsResolvedExport(origin)) {
|
|
127418
127478
|
sourceDisplay = [ts.textPart(origin.moduleSpecifier)];
|
|
127419
127479
|
if (importCompletionNode) {
|
|
127420
|
-
(_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
|
|
127480
|
+
(_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, isTypeOnlyImport, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
|
|
127421
127481
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
127422
127482
|
}
|
|
127423
127483
|
}
|
|
@@ -127490,7 +127550,7 @@ var ts;
|
|
|
127490
127550
|
moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined,
|
|
127491
127551
|
};
|
|
127492
127552
|
}
|
|
127493
|
-
function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) {
|
|
127553
|
+
function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, isTypeOnly, origin, useSemicolons, options, preferences) {
|
|
127494
127554
|
var sourceFile = importCompletionNode.getSourceFile();
|
|
127495
127555
|
var replacementSpan = ts.createTextSpanFromNode(importCompletionNode, sourceFile);
|
|
127496
127556
|
var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier);
|
|
@@ -127499,12 +127559,13 @@ var ts;
|
|
|
127499
127559
|
0 /* Named */;
|
|
127500
127560
|
var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : "";
|
|
127501
127561
|
var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true);
|
|
127562
|
+
var typeOnlyPrefix = isTypeOnly ? " " + ts.tokenToString(151 /* TypeKeyword */) + " " : " ";
|
|
127502
127563
|
var suffix = useSemicolons ? ";" : "";
|
|
127503
127564
|
switch (importKind) {
|
|
127504
|
-
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import
|
|
127505
|
-
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import
|
|
127506
|
-
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
127507
|
-
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
127565
|
+
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
127566
|
+
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
127567
|
+
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + "* as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
127568
|
+
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + "{ " + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
127508
127569
|
}
|
|
127509
127570
|
}
|
|
127510
127571
|
function quotePropertyName(sourceFile, preferences, name) {
|
|
@@ -127533,6 +127594,7 @@ var ts;
|
|
|
127533
127594
|
var start = ts.timestamp();
|
|
127534
127595
|
var variableDeclaration = getVariableDeclaration(location);
|
|
127535
127596
|
var useSemicolons = ts.probablyUsesSemicolons(sourceFile);
|
|
127597
|
+
var isTypeOnlyImport = !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent);
|
|
127536
127598
|
// Tracks unique names.
|
|
127537
127599
|
// Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
|
|
127538
127600
|
// true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
|
|
@@ -127548,7 +127610,7 @@ var ts;
|
|
|
127548
127610
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
127549
127611
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
127550
127612
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
127551
|
-
var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences);
|
|
127613
|
+
var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, isTypeOnlyImport, useSemicolons, compilerOptions, preferences);
|
|
127552
127614
|
if (!entry) {
|
|
127553
127615
|
continue;
|
|
127554
127616
|
}
|
|
@@ -128449,6 +128511,7 @@ var ts;
|
|
|
128449
128511
|
}
|
|
128450
128512
|
function isTypeOnlyCompletion() {
|
|
128451
128513
|
return insideJsDocTagTypeExpression
|
|
128514
|
+
|| !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
|
|
128452
128515
|
|| !isContextTokenValueLocation(contextToken) &&
|
|
128453
128516
|
(ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)
|
|
128454
128517
|
|| ts.isPartOfTypeNode(location)
|