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
getTypeAliasInstantiation crashes with TypeError: Cannot read properties of undefined (reading 'get') #49458
Comments
This call stack might be enough for us to go on. Generally the best way to find out how to get a smaller testcase is to attach to the tsc process with a debugger (generally In this stack I'd check the |
I haven't quite found the offending code yet, but it seems to be related to the optional variance stuff going on in fastify. I'll make a corresponding second issue there if I can pin it down. |
@RyanCavanaugh i'm experiencing a similar issue with 4:28:40 lex@FLEXBOOK :: ~/Projects/FLDV/FLDV-P026 βΉmain*βΊ Β» tsc -p tsconfig.typecheck.json 2 β΅
/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:99606
throw e;
^
TypeError: Cannot read properties of undefined (reading 'get')
at getTypeAliasInstantiation (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:51153:54)
at createMarkerType (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:57171:17)
at _loop_23 (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:57136:45)
at getVariancesWorker (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:57157:21)
at getVariances (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:57114:17)
at structuredTypeRelatedToWorker (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:56334:41)
at structuredTypeRelatedTo (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:55955:30)
at recursiveTypeRelatedTo (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:55924:30)
at isRelatedTo (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:55506:25)
at checkTypeRelatedTo (/Users/lex/Projects/FLDV/FLDV-P026/node_modules/typescript/lib/tsc.js:55166:26) would i take the same steps you outlined above to narrow down the issue further? |
I stumbled upon this error as well and decided to dig a little to the core of the problem. I made a repo with a not really minimal reproduction, but as good as possible. The imported Any of those actions will remove the error:
Unfortunately, I was not able to create a smaller reproducible case. I believe this it not the expected behaviour of the Possible temporary workaround: function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
var type = getDeclaredTypeOfSymbol(symbol);
if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
return getStringMappingType(symbol, typeArguments[0]);
}
var links = getSymbolLinks(symbol);
+ if (!links.instantiations) {
+ console.log('Links', links.escapedName, links);
+ }
var typeParameters = links.typeParameters;
var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); ..and remove the augmentation. |
@luixo Thank you! In my case, an upstream dependency updated a type I was importing to add a type parameter, meaning that I was attempting to augment a generic type without supplying the parameters correctly. Easy to solve once I knew what was going on! |
Currently experiencing this issue as well - not sure if there was any resolution. Just checking that before posting a reproduction of my application. |
We don't have a solid/minimal repro yet; one would be greatly appreciated |
Can you please specify what my reproduction (mentioned above) lacks? |
16 files plus whatever |
Here is a repro with only typescript as a dependency, and the smallest file content I could find https://github.com/LelouBil/typescript-bug-repro |
I didn't manage to simplify the example further |
Based on the repro and call stack, this is a duplicate of #53287 |
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
π Search Terms
getTypeAliasInstantiation
π Version & Regression Information
between 4.7.0-dev.20220322 and 4.7.0-dev.20220323
β― Playground Link
I haven't been able to extract a minimal test case, as it crashed, without emitting any errors. If you have any advice for how to instrument tsc to help find the location, I'd be happy to run through it and attempt to find a minimal test case.
Unfortunately, I am not able to share the repo.
π» Code
π Actual behaviour
The text was updated successfully, but these errors were encountered: