Skip to content

Commit c8d56bb

Browse files
committed
Update tsserver.js
1 parent fab273c commit c8d56bb

File tree

1 file changed

+81
-61
lines changed

1 file changed

+81
-61
lines changed

tsserver/tsserver.js

Lines changed: 81 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,8 @@ var ts;
12771277
An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." },
12781278
A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." },
12791279
A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." },
1280+
_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." },
1281+
Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." },
12801282
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
12811283
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
12821284
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -1431,7 +1433,6 @@ var ts;
14311433
Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." },
14321434
Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." },
14331435
Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." },
1434-
_0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." },
14351436
_0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." },
14361437
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
14371438
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
@@ -8967,7 +8968,6 @@ var ts;
89678968
var undefinedType = createIntrinsicType(32 | 262144, "undefined");
89688969
var nullType = createIntrinsicType(64 | 262144, "null");
89698970
var unknownType = createIntrinsicType(1, "unknown");
8970-
var resolvingType = createIntrinsicType(1, "__resolving__");
89718971
var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
89728972
var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
89738973
var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -8997,6 +8997,8 @@ var ts;
89978997
var emitExtends = false;
89988998
var emitDecorate = false;
89998999
var emitParam = false;
9000+
var resolutionTargets = [];
9001+
var resolutionResults = [];
90009002
var mergedSymbols = [];
90019003
var symbolLinks = [];
90029004
var nodeLinks = [];
@@ -9216,9 +9218,9 @@ var ts;
92169218
}
92179219
else if (location.kind === 228 ||
92189220
(location.kind === 206 && location.name.kind === 8)) {
9219-
result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & 8914931);
9221+
result = getSymbolOfNode(location).exports["default"];
92209222
var localSymbol = ts.getLocalSymbolForExportDefault(result);
9221-
if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) {
9223+
if (result && localSymbol && (result.flags & meaning) && localSymbol.name === name) {
92229224
break loop;
92239225
}
92249226
result = undefined;
@@ -9547,7 +9549,8 @@ var ts;
95479549
}
95489550
var symbol;
95499551
if (name.kind === 65) {
9550-
symbol = resolveName(name, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name);
9552+
var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0;
9553+
symbol = resolveName(name, name.text, meaning, message, name);
95519554
if (!symbol) {
95529555
return undefined;
95539556
}
@@ -10518,6 +10521,26 @@ var ts;
1051810521
});
1051910522
}
1052010523
}
10524+
function pushTypeResolution(target) {
10525+
var i = 0;
10526+
var count = resolutionTargets.length;
10527+
while (i < count && resolutionTargets[i] !== target) {
10528+
i++;
10529+
}
10530+
if (i < count) {
10531+
do {
10532+
resolutionResults[i++] = false;
10533+
} while (i < count);
10534+
return false;
10535+
}
10536+
resolutionTargets.push(target);
10537+
resolutionResults.push(true);
10538+
return true;
10539+
}
10540+
function popTypeResolution() {
10541+
resolutionTargets.pop();
10542+
return resolutionResults.pop();
10543+
}
1052110544
function getRootDeclaration(node) {
1052210545
while (node.kind === 153) {
1052310546
node = node.parent.parent;
@@ -10695,20 +10718,23 @@ var ts;
1069510718
if (declaration.kind === 215) {
1069610719
return links.type = checkExpression(declaration.expression);
1069710720
}
10698-
links.type = resolvingType;
10699-
var type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
10700-
if (links.type === resolvingType) {
10701-
links.type = type;
10721+
if (!pushTypeResolution(symbol)) {
10722+
return unknownType;
1070210723
}
10703-
}
10704-
else if (links.type === resolvingType) {
10705-
links.type = anyType;
10706-
if (compilerOptions.noImplicitAny) {
10707-
var diagnostic = symbol.valueDeclaration.type ?
10708-
ts.Diagnostics._0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation :
10709-
ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer;
10710-
error(symbol.valueDeclaration, diagnostic, symbolToString(symbol));
10724+
var type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
10725+
if (!popTypeResolution()) {
10726+
if (symbol.valueDeclaration.type) {
10727+
type = unknownType;
10728+
error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
10729+
}
10730+
else {
10731+
type = anyType;
10732+
if (compilerOptions.noImplicitAny) {
10733+
error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol));
10734+
}
10735+
}
1071110736
}
10737+
links.type = type;
1071210738
}
1071310739
return links.type;
1071410740
}
@@ -10729,13 +10755,10 @@ var ts;
1072910755
}
1073010756
function getTypeOfAccessors(symbol) {
1073110757
var links = getSymbolLinks(symbol);
10732-
checkAndStoreTypeOfAccessors(symbol, links);
10733-
return links.type;
10734-
}
10735-
function checkAndStoreTypeOfAccessors(symbol, links) {
10736-
links = links || getSymbolLinks(symbol);
1073710758
if (!links.type) {
10738-
links.type = resolvingType;
10759+
if (!pushTypeResolution(symbol)) {
10760+
return unknownType;
10761+
}
1073910762
var getter = ts.getDeclarationOfKind(symbol, 137);
1074010763
var setter = ts.getDeclarationOfKind(symbol, 138);
1074110764
var type;
@@ -10760,17 +10783,16 @@ var ts;
1076010783
}
1076110784
}
1076210785
}
10763-
if (links.type === resolvingType) {
10764-
links.type = type;
10765-
}
10766-
}
10767-
else if (links.type === resolvingType) {
10768-
links.type = anyType;
10769-
if (compilerOptions.noImplicitAny) {
10770-
var getter = ts.getDeclarationOfKind(symbol, 137);
10771-
error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
10786+
if (!popTypeResolution()) {
10787+
type = anyType;
10788+
if (compilerOptions.noImplicitAny) {
10789+
var getter_1 = ts.getDeclarationOfKind(symbol, 137);
10790+
error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
10791+
}
1077210792
}
10793+
links.type = type;
1077310794
}
10795+
return links.type;
1077410796
}
1077510797
function getTypeOfFuncClassEnumModule(symbol) {
1077610798
var links = getSymbolLinks(symbol);
@@ -10932,17 +10954,16 @@ var ts;
1093210954
function getDeclaredTypeOfTypeAlias(symbol) {
1093310955
var links = getSymbolLinks(symbol);
1093410956
if (!links.declaredType) {
10935-
links.declaredType = resolvingType;
10957+
if (!pushTypeResolution(links)) {
10958+
return unknownType;
10959+
}
1093610960
var declaration = ts.getDeclarationOfKind(symbol, 204);
1093710961
var type = getTypeFromTypeNode(declaration.type);
10938-
if (links.declaredType === resolvingType) {
10939-
links.declaredType = type;
10962+
if (!popTypeResolution()) {
10963+
type = unknownType;
10964+
error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
1094010965
}
10941-
}
10942-
else if (links.declaredType === resolvingType) {
10943-
links.declaredType = unknownType;
10944-
var declaration = ts.getDeclarationOfKind(symbol, 204);
10945-
error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
10966+
links.declaredType = type;
1094610967
}
1094710968
return links.declaredType;
1094810969
}
@@ -11481,7 +11502,9 @@ var ts;
1148111502
}
1148211503
function getReturnTypeOfSignature(signature) {
1148311504
if (!signature.resolvedReturnType) {
11484-
signature.resolvedReturnType = resolvingType;
11505+
if (!pushTypeResolution(signature)) {
11506+
return unknownType;
11507+
}
1148511508
var type;
1148611509
if (signature.target) {
1148711510
type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper);
@@ -11492,21 +11515,19 @@ var ts;
1149211515
else {
1149311516
type = getReturnTypeFromBody(signature.declaration);
1149411517
}
11495-
if (signature.resolvedReturnType === resolvingType) {
11496-
signature.resolvedReturnType = type;
11497-
}
11498-
}
11499-
else if (signature.resolvedReturnType === resolvingType) {
11500-
signature.resolvedReturnType = anyType;
11501-
if (compilerOptions.noImplicitAny) {
11502-
var declaration = signature.declaration;
11503-
if (declaration.name) {
11504-
error(declaration.name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(declaration.name));
11505-
}
11506-
else {
11507-
error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions);
11518+
if (!popTypeResolution()) {
11519+
type = anyType;
11520+
if (compilerOptions.noImplicitAny) {
11521+
var declaration = signature.declaration;
11522+
if (declaration.name) {
11523+
error(declaration.name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(declaration.name));
11524+
}
11525+
else {
11526+
error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions);
11527+
}
1150811528
}
1150911529
}
11530+
signature.resolvedReturnType = type;
1151011531
}
1151111532
return signature.resolvedReturnType;
1151211533
}
@@ -14756,10 +14777,9 @@ var ts;
1475614777
if (isContextSensitive(node)) {
1475714778
assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper);
1475814779
}
14759-
if (!node.type) {
14760-
signature.resolvedReturnType = resolvingType;
14780+
if (!node.type && !signature.resolvedReturnType) {
1476114781
var returnType = getReturnTypeFromBody(node, contextualMapper);
14762-
if (signature.resolvedReturnType === resolvingType) {
14782+
if (!signature.resolvedReturnType) {
1476314783
signature.resolvedReturnType = returnType;
1476414784
}
1476514785
}
@@ -15540,7 +15560,7 @@ var ts;
1554015560
}
1554115561
}
1554215562
}
15543-
checkAndStoreTypeOfAccessors(getSymbolOfNode(node));
15563+
getTypeOfAccessors(getSymbolOfNode(node));
1554415564
}
1554515565
checkFunctionLikeDeclaration(node);
1554615566
}
@@ -36854,11 +36874,11 @@ var ts;
3685436874
configFilename = ts.normalizePath(configFilename);
3685536875
var dirPath = ts.getDirectoryPath(configFilename);
3685636876
var rawConfig = ts.readConfigFile(configFilename);
36857-
if (!rawConfig) {
36858-
return { errorMsg: "tsconfig syntax error" };
36877+
if (rawConfig.error) {
36878+
return rawConfig.error;
3685936879
}
3686036880
else {
36861-
var parsedCommandLine = ts.parseConfigFile(rawConfig, ts.sys, dirPath);
36881+
var parsedCommandLine = ts.parseConfigFile(rawConfig.config, ts.sys, dirPath);
3686236882
if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) {
3686336883
return { errorMsg: "tsconfig option errors" };
3686436884
}

0 commit comments

Comments
 (0)