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/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.20210924";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -4734,6 +4734,7 @@ var ts;
|
|
|
4734
4734
|
CheckFlags[CheckFlags["HasNeverType"] = 131072] = "HasNeverType";
|
|
4735
4735
|
CheckFlags[CheckFlags["Mapped"] = 262144] = "Mapped";
|
|
4736
4736
|
CheckFlags[CheckFlags["StripOptional"] = 524288] = "StripOptional";
|
|
4737
|
+
CheckFlags[CheckFlags["Unresolved"] = 1048576] = "Unresolved";
|
|
4737
4738
|
CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic";
|
|
4738
4739
|
CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant";
|
|
4739
4740
|
CheckFlags[CheckFlags["Partial"] = 48] = "Partial";
|
|
@@ -46435,10 +46436,13 @@ var ts;
|
|
|
46435
46436
|
var undefinedProperties = new ts.Map();
|
|
46436
46437
|
var unknownSymbol = createSymbol(4 /* Property */, "unknown");
|
|
46437
46438
|
var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */);
|
|
46439
|
+
var unresolvedSymbols = new ts.Map();
|
|
46440
|
+
var errorTypes = new ts.Map();
|
|
46438
46441
|
var anyType = createIntrinsicType(1 /* Any */, "any");
|
|
46439
46442
|
var autoType = createIntrinsicType(1 /* Any */, "any");
|
|
46440
46443
|
var wildcardType = createIntrinsicType(1 /* Any */, "any");
|
|
46441
46444
|
var errorType = createIntrinsicType(1 /* Any */, "error");
|
|
46445
|
+
var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
|
|
46442
46446
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */);
|
|
46443
46447
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
46444
46448
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
@@ -49877,7 +49881,9 @@ var ts;
|
|
|
49877
49881
|
var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer);
|
|
49878
49882
|
if (typeNode === undefined)
|
|
49879
49883
|
return ts.Debug.fail("should always get typenode");
|
|
49880
|
-
|
|
49884
|
+
// The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`.
|
|
49885
|
+
// Otherwise, we always strip comments out.
|
|
49886
|
+
var options = { removeComments: type !== unresolvedType };
|
|
49881
49887
|
var printer = ts.createPrinter(options);
|
|
49882
49888
|
var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
|
|
49883
49889
|
printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer);
|
|
@@ -50022,6 +50028,12 @@ var ts;
|
|
|
50022
50028
|
type = getReducedType(type);
|
|
50023
50029
|
}
|
|
50024
50030
|
if (type.flags & 1 /* Any */) {
|
|
50031
|
+
if (type.aliasSymbol) {
|
|
50032
|
+
return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context));
|
|
50033
|
+
}
|
|
50034
|
+
if (type === unresolvedType) {
|
|
50035
|
+
return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved");
|
|
50036
|
+
}
|
|
50025
50037
|
context.approximateLength += 3;
|
|
50026
50038
|
return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */);
|
|
50027
50039
|
}
|
|
@@ -51110,6 +51122,10 @@ var ts;
|
|
|
51110
51122
|
}
|
|
51111
51123
|
return specifier;
|
|
51112
51124
|
}
|
|
51125
|
+
function symbolToEntityNameNode(symbol) {
|
|
51126
|
+
var identifier = ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(symbol.escapedName));
|
|
51127
|
+
return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
|
|
51128
|
+
}
|
|
51113
51129
|
function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
|
|
51114
51130
|
var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
|
|
51115
51131
|
var isTypeOf = meaning === 111551 /* Value */;
|
|
@@ -51396,7 +51412,7 @@ var ts;
|
|
|
51396
51412
|
* so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym`
|
|
51397
51413
|
*/
|
|
51398
51414
|
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
|
|
51399
|
-
if (type
|
|
51415
|
+
if (!isErrorType(type) && enclosingDeclaration) {
|
|
51400
51416
|
var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
|
|
51401
51417
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
51402
51418
|
// try to reuse the existing annotation
|
|
@@ -51419,7 +51435,7 @@ var ts;
|
|
|
51419
51435
|
return result;
|
|
51420
51436
|
}
|
|
51421
51437
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
51422
|
-
if (type
|
|
51438
|
+
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
51423
51439
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
51424
51440
|
if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) {
|
|
51425
51441
|
var annotated = getTypeFromTypeNode(annotation);
|
|
@@ -51526,7 +51542,7 @@ var ts;
|
|
|
51526
51542
|
/*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
|
|
51527
51543
|
}
|
|
51528
51544
|
}
|
|
51529
|
-
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(
|
|
51545
|
+
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) {
|
|
51530
51546
|
return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
|
|
51531
51547
|
}
|
|
51532
51548
|
if (ts.isLiteralImportTypeNode(node)) {
|
|
@@ -53154,6 +53170,11 @@ var ts;
|
|
|
53154
53170
|
function isTypeAny(type) {
|
|
53155
53171
|
return type && (type.flags & 1 /* Any */) !== 0;
|
|
53156
53172
|
}
|
|
53173
|
+
function isErrorType(type) {
|
|
53174
|
+
// The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for
|
|
53175
|
+
// a reference to an unresolved symbol. We want those to behave like the errorType.
|
|
53176
|
+
return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol);
|
|
53177
|
+
}
|
|
53157
53178
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
53158
53179
|
// assigned by contextual typing.
|
|
53159
53180
|
function getTypeForBindingElementParent(node) {
|
|
@@ -53671,7 +53692,7 @@ var ts;
|
|
|
53671
53692
|
if (!declaredType) {
|
|
53672
53693
|
return type;
|
|
53673
53694
|
}
|
|
53674
|
-
else if (declaredType
|
|
53695
|
+
else if (!isErrorType(declaredType) && !isErrorType(type) && !isTypeIdenticalTo(declaredType, type)) {
|
|
53675
53696
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
|
|
53676
53697
|
}
|
|
53677
53698
|
}
|
|
@@ -54565,7 +54586,7 @@ var ts;
|
|
|
54565
54586
|
for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
|
|
54566
54587
|
var node = implementsTypeNodes_1[_b];
|
|
54567
54588
|
var implementsType = getTypeFromTypeNode(node);
|
|
54568
|
-
if (implementsType
|
|
54589
|
+
if (!isErrorType(implementsType)) {
|
|
54569
54590
|
if (resolvedImplementsTypes === ts.emptyArray) {
|
|
54570
54591
|
resolvedImplementsTypes = [implementsType];
|
|
54571
54592
|
}
|
|
@@ -54645,7 +54666,7 @@ var ts;
|
|
|
54645
54666
|
}
|
|
54646
54667
|
baseType = getReturnTypeOfSignature(constructors[0]);
|
|
54647
54668
|
}
|
|
54648
|
-
if (baseType
|
|
54669
|
+
if (isErrorType(baseType)) {
|
|
54649
54670
|
return type.resolvedBaseTypes = ts.emptyArray;
|
|
54650
54671
|
}
|
|
54651
54672
|
var reducedBaseType = getReducedType(baseType);
|
|
@@ -54701,7 +54722,7 @@ var ts;
|
|
|
54701
54722
|
for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
|
|
54702
54723
|
var node = _c[_b];
|
|
54703
54724
|
var baseType = getReducedType(getTypeFromTypeNode(node));
|
|
54704
|
-
if (baseType
|
|
54725
|
+
if (!isErrorType(baseType)) {
|
|
54705
54726
|
if (isValidBaseType(baseType)) {
|
|
54706
54727
|
if (type !== baseType && !hasBaseType(baseType, type)) {
|
|
54707
54728
|
if (type.resolvedBaseTypes === ts.emptyArray) {
|
|
@@ -56543,7 +56564,7 @@ var ts;
|
|
|
56543
56564
|
for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) {
|
|
56544
56565
|
var current = _c[_i];
|
|
56545
56566
|
var type = getApparentType(current);
|
|
56546
|
-
if (!(type
|
|
56567
|
+
if (!(isErrorType(type) || type.flags & 131072 /* Never */)) {
|
|
56547
56568
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
56548
56569
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
56549
56570
|
if (prop) {
|
|
@@ -57493,7 +57514,7 @@ var ts;
|
|
|
57493
57514
|
}
|
|
57494
57515
|
else {
|
|
57495
57516
|
var type = getTypeFromTypeNode(constraintDeclaration);
|
|
57496
|
-
if (type.flags & 1 /* Any */ && type
|
|
57517
|
+
if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed
|
|
57497
57518
|
// use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was),
|
|
57498
57519
|
// use unknown otherwise
|
|
57499
57520
|
type = constraintDeclaration.parent.parent.kind === 194 /* MappedType */ ? keyofConstraintType : unknownType;
|
|
@@ -57665,6 +57686,18 @@ var ts;
|
|
|
57665
57686
|
* declared type. Instantiations are cached using the type identities of the type arguments as the key.
|
|
57666
57687
|
*/
|
|
57667
57688
|
function getTypeFromTypeAliasReference(node, symbol) {
|
|
57689
|
+
if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) {
|
|
57690
|
+
var typeArguments = typeArgumentsFromTypeReferenceNode(node);
|
|
57691
|
+
var id = getAliasId(symbol, typeArguments);
|
|
57692
|
+
var errorType_1 = errorTypes.get(id);
|
|
57693
|
+
if (!errorType_1) {
|
|
57694
|
+
errorType_1 = createIntrinsicType(1 /* Any */, "error");
|
|
57695
|
+
errorType_1.aliasSymbol = symbol;
|
|
57696
|
+
errorType_1.aliasTypeArguments = typeArguments;
|
|
57697
|
+
errorTypes.set(id, errorType_1);
|
|
57698
|
+
}
|
|
57699
|
+
return errorType_1;
|
|
57700
|
+
}
|
|
57668
57701
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
57669
57702
|
var typeParameters = getSymbolLinks(symbol).typeParameters;
|
|
57670
57703
|
if (typeParameters) {
|
|
@@ -57706,11 +57739,37 @@ var ts;
|
|
|
57706
57739
|
}
|
|
57707
57740
|
return undefined;
|
|
57708
57741
|
}
|
|
57709
|
-
function
|
|
57710
|
-
|
|
57742
|
+
function getSymbolPath(symbol) {
|
|
57743
|
+
return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName;
|
|
57744
|
+
}
|
|
57745
|
+
function getUnresolvedSymbolForEntityName(name) {
|
|
57746
|
+
var identifier = name.kind === 160 /* QualifiedName */ ? name.right :
|
|
57747
|
+
name.kind === 205 /* PropertyAccessExpression */ ? name.name :
|
|
57748
|
+
name;
|
|
57749
|
+
var text = identifier.escapedText;
|
|
57750
|
+
if (text) {
|
|
57751
|
+
var parentSymbol = name.kind === 160 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) :
|
|
57752
|
+
name.kind === 205 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) :
|
|
57753
|
+
undefined;
|
|
57754
|
+
var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text;
|
|
57755
|
+
var result = unresolvedSymbols.get(path);
|
|
57756
|
+
if (!result) {
|
|
57757
|
+
unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */));
|
|
57758
|
+
result.parent = parentSymbol;
|
|
57759
|
+
result.declaredType = unresolvedType;
|
|
57760
|
+
}
|
|
57761
|
+
return result;
|
|
57762
|
+
}
|
|
57763
|
+
return unknownSymbol;
|
|
57764
|
+
}
|
|
57765
|
+
function resolveTypeReferenceName(typeReference, meaning, ignoreErrors) {
|
|
57766
|
+
var name = getTypeReferenceName(typeReference);
|
|
57767
|
+
if (!name) {
|
|
57711
57768
|
return unknownSymbol;
|
|
57712
57769
|
}
|
|
57713
|
-
|
|
57770
|
+
var symbol = resolveEntityName(name, meaning, ignoreErrors);
|
|
57771
|
+
return symbol && symbol !== unknownSymbol ? symbol :
|
|
57772
|
+
ignoreErrors ? unknownSymbol : getUnresolvedSymbolForEntityName(name);
|
|
57714
57773
|
}
|
|
57715
57774
|
function getTypeReferenceType(node, symbol) {
|
|
57716
57775
|
if (symbol === unknownSymbol) {
|
|
@@ -57735,7 +57794,7 @@ var ts;
|
|
|
57735
57794
|
}
|
|
57736
57795
|
else {
|
|
57737
57796
|
// Resolve the type reference as a Type for the purpose of reporting errors.
|
|
57738
|
-
resolveTypeReferenceName(
|
|
57797
|
+
resolveTypeReferenceName(node, 788968 /* Type */);
|
|
57739
57798
|
return getTypeOfSymbol(symbol);
|
|
57740
57799
|
}
|
|
57741
57800
|
}
|
|
@@ -57879,18 +57938,18 @@ var ts;
|
|
|
57879
57938
|
if (isJSDocTypeReference(node)) {
|
|
57880
57939
|
type = getIntendedTypeFromJSDocTypeReference(node);
|
|
57881
57940
|
if (!type) {
|
|
57882
|
-
symbol = resolveTypeReferenceName(
|
|
57941
|
+
symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true);
|
|
57883
57942
|
if (symbol === unknownSymbol) {
|
|
57884
|
-
symbol = resolveTypeReferenceName(
|
|
57943
|
+
symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */);
|
|
57885
57944
|
}
|
|
57886
57945
|
else {
|
|
57887
|
-
resolveTypeReferenceName(
|
|
57946
|
+
resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
|
|
57888
57947
|
}
|
|
57889
57948
|
type = getTypeReferenceType(node, symbol);
|
|
57890
57949
|
}
|
|
57891
57950
|
}
|
|
57892
57951
|
if (!type) {
|
|
57893
|
-
symbol = resolveTypeReferenceName(
|
|
57952
|
+
symbol = resolveTypeReferenceName(node, meaning);
|
|
57894
57953
|
type = getTypeReferenceType(node, symbol);
|
|
57895
57954
|
}
|
|
57896
57955
|
// Cache both the resolved symbol and the resolved type. The resolved symbol is needed when we check the
|
|
@@ -58151,7 +58210,7 @@ var ts;
|
|
|
58151
58210
|
function mayResolveTypeAlias(node) {
|
|
58152
58211
|
switch (node.kind) {
|
|
58153
58212
|
case 177 /* TypeReference */:
|
|
58154
|
-
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node
|
|
58213
|
+
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */);
|
|
58155
58214
|
case 180 /* TypeQuery */:
|
|
58156
58215
|
return true;
|
|
58157
58216
|
case 192 /* TypeOperator */:
|
|
@@ -60680,7 +60739,7 @@ var ts;
|
|
|
60680
60739
|
var mappedTypeVariable = instantiateType(typeVariable, mapper);
|
|
60681
60740
|
if (typeVariable !== mappedTypeVariable) {
|
|
60682
60741
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
60683
|
-
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t
|
|
60742
|
+
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
60684
60743
|
if (!type.declaration.nameType) {
|
|
60685
60744
|
if (isArrayType(t)) {
|
|
60686
60745
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
@@ -60722,7 +60781,7 @@ var ts;
|
|
|
60722
60781
|
}
|
|
60723
60782
|
function instantiateMappedArrayType(arrayType, mappedType, mapper) {
|
|
60724
60783
|
var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper);
|
|
60725
|
-
return elementType
|
|
60784
|
+
return isErrorType(elementType) ? errorType :
|
|
60726
60785
|
createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
|
|
60727
60786
|
}
|
|
60728
60787
|
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
@@ -62304,7 +62363,7 @@ var ts;
|
|
|
62304
62363
|
var targetTypes = target.types;
|
|
62305
62364
|
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
62306
62365
|
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
62307
|
-
if (intrinsicAttributes
|
|
62366
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
62308
62367
|
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
62309
62368
|
// do not report top error
|
|
62310
62369
|
return result;
|
|
@@ -69281,8 +69340,7 @@ var ts;
|
|
|
69281
69340
|
if (result) {
|
|
69282
69341
|
return result;
|
|
69283
69342
|
}
|
|
69284
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) {
|
|
69285
|
-
// This is less a contextual type and more an implied shape - in some cases, this may be undesirable
|
|
69343
|
+
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
|
|
69286
69344
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
69287
69345
|
}
|
|
69288
69346
|
}
|
|
@@ -69863,7 +69921,7 @@ var ts;
|
|
|
69863
69921
|
var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
|
|
69864
69922
|
propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
|
|
69865
69923
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
69866
|
-
if (intrinsicAttribs
|
|
69924
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
69867
69925
|
propsType = intersectTypes(intrinsicAttribs, propsType);
|
|
69868
69926
|
}
|
|
69869
69927
|
return propsType;
|
|
@@ -69956,7 +70014,7 @@ var ts;
|
|
|
69956
70014
|
// Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
|
|
69957
70015
|
var apparentAttributesType = attributesType;
|
|
69958
70016
|
var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
|
|
69959
|
-
if (intrinsicClassAttribs
|
|
70017
|
+
if (!isErrorType(intrinsicClassAttribs)) {
|
|
69960
70018
|
var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
|
|
69961
70019
|
var hostClassType = getReturnTypeOfSignature(sig);
|
|
69962
70020
|
apparentAttributesType = intersectTypes(typeParams
|
|
@@ -69964,7 +70022,7 @@ var ts;
|
|
|
69964
70022
|
: intrinsicClassAttribs, apparentAttributesType);
|
|
69965
70023
|
}
|
|
69966
70024
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
69967
|
-
if (intrinsicAttribs
|
|
70025
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
69968
70026
|
apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
|
|
69969
70027
|
}
|
|
69970
70028
|
return apparentAttributesType;
|
|
@@ -70432,7 +70490,7 @@ var ts;
|
|
|
70432
70490
|
checkSpreadPropOverrides(mergedType, allPropertiesTable, memberDecl);
|
|
70433
70491
|
}
|
|
70434
70492
|
offset = propertiesArray.length;
|
|
70435
|
-
if (spread
|
|
70493
|
+
if (isErrorType(spread)) {
|
|
70436
70494
|
continue;
|
|
70437
70495
|
}
|
|
70438
70496
|
spread = getSpreadType(spread, mergedType, node.symbol, objectFlags, inConstContext);
|
|
@@ -70489,7 +70547,7 @@ var ts;
|
|
|
70489
70547
|
}
|
|
70490
70548
|
}
|
|
70491
70549
|
}
|
|
70492
|
-
if (spread
|
|
70550
|
+
if (isErrorType(spread)) {
|
|
70493
70551
|
return errorType;
|
|
70494
70552
|
}
|
|
70495
70553
|
if (spread !== emptyObjectType) {
|
|
@@ -70756,7 +70814,7 @@ var ts;
|
|
|
70756
70814
|
var links = getNodeLinks(node);
|
|
70757
70815
|
if (!links.resolvedSymbol) {
|
|
70758
70816
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
|
|
70759
|
-
if (intrinsicElementsType
|
|
70817
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
70760
70818
|
// Property case
|
|
70761
70819
|
if (!ts.isIdentifier(node.tagName))
|
|
70762
70820
|
return ts.Debug.fail();
|
|
@@ -70919,7 +70977,7 @@ var ts;
|
|
|
70919
70977
|
// var CustomTag: "h1" = "h1";
|
|
70920
70978
|
// <CustomTag> Hello World </CustomTag>
|
|
70921
70979
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
|
|
70922
|
-
if (intrinsicElementsType
|
|
70980
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
70923
70981
|
var stringLiteralTypeName = type.value;
|
|
70924
70982
|
var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
|
|
70925
70983
|
if (intrinsicProp) {
|
|
@@ -70987,7 +71045,7 @@ var ts;
|
|
|
70987
71045
|
}
|
|
70988
71046
|
function getJsxElementClassTypeAt(location) {
|
|
70989
71047
|
var type = getJsxType(JsxNames.ElementClass, location);
|
|
70990
|
-
if (type
|
|
71048
|
+
if (isErrorType(type))
|
|
70991
71049
|
return undefined;
|
|
70992
71050
|
return type;
|
|
70993
71051
|
}
|
|
@@ -71293,7 +71351,7 @@ var ts;
|
|
|
71293
71351
|
}
|
|
71294
71352
|
function checkNonNullNonVoidType(type, node) {
|
|
71295
71353
|
var nonNullType = checkNonNullType(type, node);
|
|
71296
|
-
if (nonNullType
|
|
71354
|
+
if (nonNullType.flags & 16384 /* Void */) {
|
|
71297
71355
|
error(node, ts.Diagnostics.Object_is_possibly_undefined);
|
|
71298
71356
|
}
|
|
71299
71357
|
return nonNullType;
|
|
@@ -71410,7 +71468,7 @@ var ts;
|
|
|
71410
71468
|
}
|
|
71411
71469
|
if (isAnyLike) {
|
|
71412
71470
|
if (lexicallyScopedSymbol) {
|
|
71413
|
-
return apparentType;
|
|
71471
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
71414
71472
|
}
|
|
71415
71473
|
if (!ts.getContainingClass(right)) {
|
|
71416
71474
|
grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
@@ -71434,7 +71492,8 @@ var ts;
|
|
|
71434
71492
|
if (ts.isIdentifier(left) && parentSymbol) {
|
|
71435
71493
|
markAliasReferenced(parentSymbol, node);
|
|
71436
71494
|
}
|
|
71437
|
-
return apparentType;
|
|
71495
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
71496
|
+
;
|
|
71438
71497
|
}
|
|
71439
71498
|
prop = getPropertyOfType(apparentType, right.escapedText);
|
|
71440
71499
|
}
|
|
@@ -71893,7 +71952,7 @@ var ts;
|
|
|
71893
71952
|
}
|
|
71894
71953
|
function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
|
|
71895
71954
|
// Short-circuiting for improved performance.
|
|
71896
|
-
if (
|
|
71955
|
+
if (isTypeAny(type)) {
|
|
71897
71956
|
return true;
|
|
71898
71957
|
}
|
|
71899
71958
|
var prop = getPropertyOfType(type, propertyName);
|
|
@@ -71911,7 +71970,7 @@ var ts;
|
|
|
71911
71970
|
*/
|
|
71912
71971
|
function isPropertyAccessible(node, isSuper, isWrite, containingType, property) {
|
|
71913
71972
|
// Short-circuiting for improved performance.
|
|
71914
|
-
if (
|
|
71973
|
+
if (isTypeAny(containingType)) {
|
|
71915
71974
|
return true;
|
|
71916
71975
|
}
|
|
71917
71976
|
// A #private property access in an optional chain is an error dealt with by the parser.
|
|
@@ -71982,7 +72041,7 @@ var ts;
|
|
|
71982
72041
|
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
|
|
71983
72042
|
var indexExpression = node.argumentExpression;
|
|
71984
72043
|
var indexType = checkExpression(indexExpression);
|
|
71985
|
-
if (objectType
|
|
72044
|
+
if (isErrorType(objectType) || objectType === silentNeverType) {
|
|
71986
72045
|
return objectType;
|
|
71987
72046
|
}
|
|
71988
72047
|
if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
|
|
@@ -72227,7 +72286,7 @@ var ts;
|
|
|
72227
72286
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
72228
72287
|
// return type of 'wrap'.
|
|
72229
72288
|
if (node.kind !== 164 /* Decorator */) {
|
|
72230
|
-
var contextualType = getContextualType(node, 8 /* SkipBindingPatterns */);
|
|
72289
|
+
var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
72231
72290
|
if (contextualType) {
|
|
72232
72291
|
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
72233
72292
|
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
@@ -73176,7 +73235,7 @@ var ts;
|
|
|
73176
73235
|
}
|
|
73177
73236
|
return anySignature;
|
|
73178
73237
|
}
|
|
73179
|
-
if (superType
|
|
73238
|
+
if (!isErrorType(superType)) {
|
|
73180
73239
|
// In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated
|
|
73181
73240
|
// with the type arguments specified in the extends clause.
|
|
73182
73241
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
|
|
@@ -73204,7 +73263,7 @@ var ts;
|
|
|
73204
73263
|
return silentNeverSignature;
|
|
73205
73264
|
}
|
|
73206
73265
|
var apparentType = getApparentType(funcType);
|
|
73207
|
-
if (apparentType
|
|
73266
|
+
if (isErrorType(apparentType)) {
|
|
73208
73267
|
// Another error has already been reported
|
|
73209
73268
|
return resolveErrorCall(node);
|
|
73210
73269
|
}
|
|
@@ -73220,7 +73279,7 @@ var ts;
|
|
|
73220
73279
|
if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
|
|
73221
73280
|
// The unknownType indicates that an error already occurred (and was reported). No
|
|
73222
73281
|
// need to report another error in this case.
|
|
73223
|
-
if (funcType
|
|
73282
|
+
if (!isErrorType(funcType) && node.typeArguments) {
|
|
73224
73283
|
error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
|
73225
73284
|
}
|
|
73226
73285
|
return resolveUntypedCall(node);
|
|
@@ -73297,7 +73356,7 @@ var ts;
|
|
|
73297
73356
|
// signatures for overload resolution. The result type of the function call becomes
|
|
73298
73357
|
// the result type of the operation.
|
|
73299
73358
|
expressionType = getApparentType(expressionType);
|
|
73300
|
-
if (expressionType
|
|
73359
|
+
if (isErrorType(expressionType)) {
|
|
73301
73360
|
// Another error has already been reported
|
|
73302
73361
|
return resolveErrorCall(node);
|
|
73303
73362
|
}
|
|
@@ -73512,7 +73571,7 @@ var ts;
|
|
|
73512
73571
|
function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
|
|
73513
73572
|
var tagType = checkExpression(node.tag);
|
|
73514
73573
|
var apparentType = getApparentType(tagType);
|
|
73515
|
-
if (apparentType
|
|
73574
|
+
if (isErrorType(apparentType)) {
|
|
73516
73575
|
// Another error has already been reported
|
|
73517
73576
|
return resolveErrorCall(node);
|
|
73518
73577
|
}
|
|
@@ -73558,7 +73617,7 @@ var ts;
|
|
|
73558
73617
|
function resolveDecorator(node, candidatesOutArray, checkMode) {
|
|
73559
73618
|
var funcType = checkExpression(node.expression);
|
|
73560
73619
|
var apparentType = getApparentType(funcType);
|
|
73561
|
-
if (apparentType
|
|
73620
|
+
if (isErrorType(apparentType)) {
|
|
73562
73621
|
return resolveErrorCall(node);
|
|
73563
73622
|
}
|
|
73564
73623
|
var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
|
|
@@ -73613,7 +73672,7 @@ var ts;
|
|
|
73613
73672
|
}
|
|
73614
73673
|
var exprTypes = checkExpression(node.tagName);
|
|
73615
73674
|
var apparentType = getApparentType(exprTypes);
|
|
73616
|
-
if (apparentType
|
|
73675
|
+
if (isErrorType(apparentType)) {
|
|
73617
73676
|
return resolveErrorCall(node);
|
|
73618
73677
|
}
|
|
73619
73678
|
var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
|
|
@@ -73936,7 +73995,7 @@ var ts;
|
|
|
73936
73995
|
}
|
|
73937
73996
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
|
|
73938
73997
|
var _a;
|
|
73939
|
-
if (allowSyntheticDefaultImports && type && type
|
|
73998
|
+
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
73940
73999
|
var synthType = type;
|
|
73941
74000
|
if (!synthType.syntheticType) {
|
|
73942
74001
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
@@ -74042,7 +74101,7 @@ var ts;
|
|
|
74042
74101
|
checkSourceElement(type);
|
|
74043
74102
|
exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
|
|
74044
74103
|
var targetType = getTypeFromTypeNode(type);
|
|
74045
|
-
if (produceDiagnostics && targetType
|
|
74104
|
+
if (produceDiagnostics && !isErrorType(targetType)) {
|
|
74046
74105
|
var widenedType = getWidenedType(exprType);
|
|
74047
74106
|
if (!isTypeComparableTo(targetType, widenedType)) {
|
|
74048
74107
|
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);
|
|
@@ -74075,7 +74134,7 @@ var ts;
|
|
|
74075
74134
|
return getGlobalImportMetaExpressionType();
|
|
74076
74135
|
case 103 /* NewKeyword */:
|
|
74077
74136
|
var type = checkNewTargetMetaProperty(node);
|
|
74078
|
-
return type
|
|
74137
|
+
return isErrorType(type) ? errorType : createNewTargetExpressionType(type);
|
|
74079
74138
|
default:
|
|
74080
74139
|
ts.Debug.assertNever(node.keywordToken);
|
|
74081
74140
|
}
|
|
@@ -75068,7 +75127,7 @@ var ts;
|
|
|
75068
75127
|
}
|
|
75069
75128
|
var operandType = checkExpression(node.expression);
|
|
75070
75129
|
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);
|
|
75071
|
-
if (awaitedType === operandType && awaitedType
|
|
75130
|
+
if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
|
|
75072
75131
|
addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
|
|
75073
75132
|
}
|
|
75074
75133
|
return awaitedType;
|
|
@@ -75709,7 +75768,7 @@ var ts;
|
|
|
75709
75768
|
else if (isTypeAny(leftType) || isTypeAny(rightType)) {
|
|
75710
75769
|
// Otherwise, the result is of type Any.
|
|
75711
75770
|
// NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
|
|
75712
|
-
resultType = leftType
|
|
75771
|
+
resultType = isErrorType(leftType) || isErrorType(rightType) ? errorType : anyType;
|
|
75713
75772
|
}
|
|
75714
75773
|
// Symbols are not allowed at all in arithmetic expressions
|
|
75715
75774
|
if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
|
|
@@ -77187,7 +77246,7 @@ var ts;
|
|
|
77187
77246
|
}
|
|
77188
77247
|
function getTypeParametersForTypeReference(node) {
|
|
77189
77248
|
var type = getTypeFromTypeReference(node);
|
|
77190
|
-
if (type
|
|
77249
|
+
if (!isErrorType(type)) {
|
|
77191
77250
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
77192
77251
|
if (symbol) {
|
|
77193
77252
|
return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters ||
|
|
@@ -77203,7 +77262,7 @@ var ts;
|
|
|
77203
77262
|
}
|
|
77204
77263
|
ts.forEach(node.typeArguments, checkSourceElement);
|
|
77205
77264
|
var type = getTypeFromTypeReference(node);
|
|
77206
|
-
if (type
|
|
77265
|
+
if (!isErrorType(type)) {
|
|
77207
77266
|
if (node.typeArguments && produceDiagnostics) {
|
|
77208
77267
|
var typeParameters = getTypeParametersForTypeReference(node);
|
|
77209
77268
|
if (typeParameters) {
|
|
@@ -78029,7 +78088,7 @@ var ts;
|
|
|
78029
78088
|
//
|
|
78030
78089
|
var returnType = getTypeFromTypeNode(returnTypeNode);
|
|
78031
78090
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
78032
|
-
if (returnType
|
|
78091
|
+
if (isErrorType(returnType)) {
|
|
78033
78092
|
return;
|
|
78034
78093
|
}
|
|
78035
78094
|
var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true);
|
|
@@ -78043,7 +78102,7 @@ var ts;
|
|
|
78043
78102
|
else {
|
|
78044
78103
|
// Always mark the type node as referenced if it points to a value
|
|
78045
78104
|
markTypeNodeAsReferenced(returnTypeNode);
|
|
78046
|
-
if (returnType
|
|
78105
|
+
if (isErrorType(returnType)) {
|
|
78047
78106
|
return;
|
|
78048
78107
|
}
|
|
78049
78108
|
var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
|
|
@@ -78053,7 +78112,7 @@ var ts;
|
|
|
78053
78112
|
}
|
|
78054
78113
|
var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true);
|
|
78055
78114
|
var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
|
|
78056
|
-
if (promiseConstructorType
|
|
78115
|
+
if (isErrorType(promiseConstructorType)) {
|
|
78057
78116
|
if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) {
|
|
78058
78117
|
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);
|
|
78059
78118
|
}
|
|
@@ -79105,7 +79164,7 @@ var ts;
|
|
|
79105
79164
|
// Node is a secondary declaration, check that type is identical to primary declaration and check that
|
|
79106
79165
|
// initializer is consistent with type associated with the node
|
|
79107
79166
|
var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
|
|
79108
|
-
if (type
|
|
79167
|
+
if (!isErrorType(type) && !isErrorType(declarationType) &&
|
|
79109
79168
|
!isTypeIdenticalTo(type, declarationType) &&
|
|
79110
79169
|
!(symbol.flags & 67108864 /* Assignment */)) {
|
|
79111
79170
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
|
|
@@ -80603,7 +80662,7 @@ var ts;
|
|
|
80603
80662
|
checkTypeReferenceNode(typeRefNode);
|
|
80604
80663
|
if (produceDiagnostics) {
|
|
80605
80664
|
var t = getReducedType(getTypeFromTypeNode(typeRefNode));
|
|
80606
|
-
if (t
|
|
80665
|
+
if (!isErrorType(t)) {
|
|
80607
80666
|
if (isValidBaseType(t)) {
|
|
80608
80667
|
var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
|
|
80609
80668
|
ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
|
|
@@ -82643,7 +82702,8 @@ var ts;
|
|
|
82643
82702
|
}
|
|
82644
82703
|
else if (isTypeReferenceIdentifier(name)) {
|
|
82645
82704
|
var meaning = name.parent.kind === 177 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */;
|
|
82646
|
-
|
|
82705
|
+
var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
|
|
82706
|
+
return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name);
|
|
82647
82707
|
}
|
|
82648
82708
|
if (name.parent.kind === 176 /* TypePredicate */) {
|
|
82649
82709
|
return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */);
|
|
@@ -82870,7 +82930,7 @@ var ts;
|
|
|
82870
82930
|
var symbol = getSymbolAtLocation(node);
|
|
82871
82931
|
if (symbol) {
|
|
82872
82932
|
var declaredType = getDeclaredTypeOfSymbol(symbol);
|
|
82873
|
-
return declaredType
|
|
82933
|
+
return !isErrorType(declaredType) ? declaredType : getTypeOfSymbol(symbol);
|
|
82874
82934
|
}
|
|
82875
82935
|
}
|
|
82876
82936
|
if (ts.isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
@@ -83368,7 +83428,7 @@ var ts;
|
|
|
83368
83428
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83369
83429
|
}
|
|
83370
83430
|
var type = getDeclaredTypeOfSymbol(typeSymbol);
|
|
83371
|
-
if (type
|
|
83431
|
+
if (isErrorType(type)) {
|
|
83372
83432
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83373
83433
|
}
|
|
83374
83434
|
else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
@@ -126781,7 +126841,7 @@ var ts;
|
|
|
126781
126841
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
126782
126842
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
126783
126843
|
}
|
|
126784
|
-
function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) {
|
|
126844
|
+
function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, isTypeOnlyImport, useSemicolons, options, preferences) {
|
|
126785
126845
|
var _a;
|
|
126786
126846
|
var insertText;
|
|
126787
126847
|
var replacementSpan = ts.getReplacementSpanForContextToken(contextToken);
|
|
@@ -126835,7 +126895,7 @@ var ts;
|
|
|
126835
126895
|
if (originIsResolvedExport(origin)) {
|
|
126836
126896
|
sourceDisplay = [ts.textPart(origin.moduleSpecifier)];
|
|
126837
126897
|
if (importCompletionNode) {
|
|
126838
|
-
(_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
|
|
126898
|
+
(_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, isTypeOnlyImport, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
|
|
126839
126899
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
126840
126900
|
}
|
|
126841
126901
|
}
|
|
@@ -126908,7 +126968,7 @@ var ts;
|
|
|
126908
126968
|
moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined,
|
|
126909
126969
|
};
|
|
126910
126970
|
}
|
|
126911
|
-
function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) {
|
|
126971
|
+
function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, isTypeOnly, origin, useSemicolons, options, preferences) {
|
|
126912
126972
|
var sourceFile = importCompletionNode.getSourceFile();
|
|
126913
126973
|
var replacementSpan = ts.createTextSpanFromNode(importCompletionNode, sourceFile);
|
|
126914
126974
|
var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier);
|
|
@@ -126917,12 +126977,13 @@ var ts;
|
|
|
126917
126977
|
0 /* Named */;
|
|
126918
126978
|
var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : "";
|
|
126919
126979
|
var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true);
|
|
126980
|
+
var typeOnlyPrefix = isTypeOnly ? " " + ts.tokenToString(151 /* TypeKeyword */) + " " : " ";
|
|
126920
126981
|
var suffix = useSemicolons ? ";" : "";
|
|
126921
126982
|
switch (importKind) {
|
|
126922
|
-
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import
|
|
126923
|
-
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import
|
|
126924
|
-
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
126925
|
-
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
126983
|
+
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
126984
|
+
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
126985
|
+
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + "* as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
126986
|
+
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + "{ " + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
126926
126987
|
}
|
|
126927
126988
|
}
|
|
126928
126989
|
function quotePropertyName(sourceFile, preferences, name) {
|
|
@@ -126951,6 +127012,7 @@ var ts;
|
|
|
126951
127012
|
var start = ts.timestamp();
|
|
126952
127013
|
var variableDeclaration = getVariableDeclaration(location);
|
|
126953
127014
|
var useSemicolons = ts.probablyUsesSemicolons(sourceFile);
|
|
127015
|
+
var isTypeOnlyImport = !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent);
|
|
126954
127016
|
// Tracks unique names.
|
|
126955
127017
|
// Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
|
|
126956
127018
|
// true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
|
|
@@ -126966,7 +127028,7 @@ var ts;
|
|
|
126966
127028
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
126967
127029
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
126968
127030
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
126969
|
-
var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences);
|
|
127031
|
+
var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, isTypeOnlyImport, useSemicolons, compilerOptions, preferences);
|
|
126970
127032
|
if (!entry) {
|
|
126971
127033
|
continue;
|
|
126972
127034
|
}
|
|
@@ -127867,6 +127929,7 @@ var ts;
|
|
|
127867
127929
|
}
|
|
127868
127930
|
function isTypeOnlyCompletion() {
|
|
127869
127931
|
return insideJsDocTagTypeExpression
|
|
127932
|
+
|| !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
|
|
127870
127933
|
|| !isContextTokenValueLocation(contextToken) &&
|
|
127871
127934
|
(ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)
|
|
127872
127935
|
|| ts.isPartOfTypeNode(location)
|