-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsc and tsserver have different ideas of excessively deep types #32573
Comments
This is probably an effect of the different check order. tsserver checks the currently open file first. That causes different evaluation order and caching for type instantiations. |
Also, I'd like to note (again) that TS 3.5.1 builds this particular project in like 4-7 seconds (this includes the "problematic" file and lots of other files). @ajafff Some versions are okay, though =P |
In my repro, If I remove the file from
If I add the offending file to a new
[Edit] |
Just for reference, I set the limit to 4,000,000, var instantiationCount = 0;
var maxCount = 0;
function checkMaxCount (node) {
if (instantiationCount > maxCount) {
maxCount = instantiationCount;
if (node.declarationList) {
console.log("max count", instantiationCount, node);
}
}
} checkMaxCount(node);
instantiationCount = 0; if (instantiationDepth === 50 || instantiationCount >= 4000000) {
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
return errorType;
} This is the [ Node {
pos: 959,
end: 971,
kind: 238,
id: 0,
flags: 4194304,
modifierFlagsCache: 536870912,
transformFlags: 0,
parent:
Node {
pos: 955,
end: 971,
kind: 239,
id: 0,
flags: 4194304,
modifierFlagsCache: 0,
transformFlags: 0,
parent: [Node],
original: undefined,
declarations: [Circular] },
original: undefined,
name:
Node {
pos: 959,
end: 963,
kind: 73,
id: 0,
flags: 4194304,
modifierFlagsCache: 0,
transformFlags: 0,
parent: [Circular],
original: undefined,
escapedText: 'NaN',
flowNode: [Object] },
type:
Node {
pos: 964,
end: 971,
kind: 136,
id: 0,
flags: 4194304,
modifierFlagsCache: 0,
transformFlags: 0,
parent: [Circular],
original: undefined },
initializer: undefined,
symbol:
Symbol {
flags: 1,
escapedName: 'NaN',
declarations: [Array],
valueDeclaration: [Circular],
id: undefined,
mergeId: undefined,
parent: undefined,
exports: Map {} } },
pos: 959,
end: 971 ] So, When I print out the Node {
pos: 0,
end: 972,
kind: 220,
id: 0,
flags: 4194304,
modifierFlagsCache: 536870914,
transformFlags: 0,
parent:
Node {
pos: 0,
end: 207082,
kind: 285,
id: 13293,
flags: 4194336,
modifierFlagsCache: 0,
transformFlags: 0,
parent: undefined,
original: undefined,
text:
'/*! *****************************************************************************\nCopyright (c) Microsoft Corporation. All rights reserved. \nLicensed under the Apache License, Version 2.0 (the "License"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0 \n \nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, \nMERCHANTABLITY OR NON-INFRINGEMENT. \n \nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\n\n\n\n/// <reference no-default-lib="true"/>\r\n\n\n/////////////////////////////\r\n/// ECMAScript APIs\r\n/////////////////////////////\r\n\r\ndeclare var NaN: number;\r\ndeclare var Infinity: number;\r\n\r\n/**\r\n * Evaluates JavaScript code and executes it.\r\n * @param x A String value that contains valid JavaScript code.\r\n */\r\ndeclare function eval(x: string): any;\r\n\r\n/**\r\n * Converts a string to an integer.\r\n * @param s A string to convert into a number.\r\n * @param radix A value between 2 and 36 that specifies the base of the number in numString.\r\n * If this argument is not supplied, strings with a prefix of \'0x\
/*snip*/
s An object that contains one or more properties that specify comparison options.\r\n */\r\n toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;\r\n}\r\n',
bindDiagnostics: [],
bindSuggestionDiagnostics: undefined,
languageVersion: 99,
fileName:
'/home/anyhowstep/node-projects/14m-vs-5m/node_modules/typescript/lib/lib.es5.d.ts',
languageVariant: 0,
isDeclarationFile: true,
scriptKind: 3,
pragmas: Map { 'reference' => [Object] },
checkJsDirective: undefined,
referencedFiles: [],
typeReferenceDirectives: [],
libReferenceDirectives: [],
amdDependencies: [],
hasNoDefaultLib: true,
statements:
[ [Circular],
[Node],
[Node],
/*snip*/
[Node],
... 40 more items,
pos: 0,
end: 207080 ],
endOfFileToken:
Node {
pos: 207080,
end: 207082,
kind: 1,
id: 0,
flags: 4194304,
modifierFlagsCache: 0,
transformFlags: 0,
parent: [Circular],
original: undefined },
externalModuleIndicator: undefined,
nodeCount: 13032,
identifierCount: 4120,
identifiers:
Map {
'NaN' => 'NaN',
'Infinity' => 'Infinity',
/*snip*/ |
Uhh... So, going back to the original project I have for work,
It doesn't even tell me what node is causing the problem! My process was this,
However, now I get the max depth/count error and there is no file or line number. So, I added the And it's the same So, for some projects, it gives 4.9M instantiations. And for others, > 5M and craps out. |
I made the limit 14 million. It built fine. But the
When I take the
How does |
|
I changed it to,
|
Sorry for the spam =( I'm just anxious that my code will break with 3.6 and I won't be able to migrate my projects. I think one of my gripes with this situation is that I've now discovered I can get the max count error and not know how to fix it because I'd like to stress again that in 3.5.1, these files compile in mere seconds. So it's not like having 14M, 16M, 20M instantiations is actually a real problem. And inspecting the node just tells me I can't just not use 99% sure I just have the wrong idea and I'm inspecting the wrong things and drawing the wrong conclusion. But I still don't know where the count hits 13.8M What should I look out for when trying to find the 13.8M culprit? Any variables I should be monitoring besides |
@weswigham 's comment here jumped out at me,
Because it's related to this,
And this,
|
TypeScript Version:
typescript-3.6.0-insiders.20190725
https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/37759/artifacts?artifactName=tgz&fileId=2A7E3F3E93DD6F833D63A63F3A7A21707B3F57B08FCA5C93A8F1848556D8141F02&fileName=/typescript-3.6.0-insiders.20190725.tgz
Taken from,
#32028 (comment)
Search Terms:
max instantiation count, max instantiation depth, tsc, tsserver
Code
I've reduced the 40-subproject monorepo to just small parts of 2 subprojects.
Here is a snippet of the problem,
Expected behavior:
If
tsc
gets the error,Then
tsserver
should also get the errorActual behavior:
tsc
gets the error, buttsserver
does not (or at least VS code infers the type correctly without errors)Playground Link:
-None-
@sheetalkamat
The project involved contains code related to a company project.
So, I really do not want to upload it publicly, if possible.
I could mangle the variable names so that they're meaningless but if I can just email the parts of the project that are involved, that would be nice.
Repro steps:
npm install
npm run build
TS2589: Type instantiation is excessively deep and possibly infinite.
tsc
says contains errorsRelated Issues:
The merged PR that introduced the error,
#32079 (comment)
The build I am testing,
#32028
Also relevant, #29511
It seems like every few versions, there ends up being a difference between
tsc
andtsserver
, regarding the max instantiation depthThe text was updated successfully, but these errors were encountered: