Skip to content

TypeError: Cannot read properties of undefined (reading 'get') at getTypeAliasInstantiation #53287

@Itrulia

Description

@Itrulia

Bug Report

🔎 Search Terms

getTypeAliasInstantiation, (reading 'get'), TypeError: Cannot read properties of undefined, createMarkerType

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ~4.6.0 and ~4.7.0 and is still present in 4.9.5

We have only now figured out something went wrong as we used babel to transpile and fork-ts-checker-webpack-plugin to type check. This caused the type checking to silently fail, which has caused a few bugs lately.

⏯ Playground Link

I don't have a Playground Link as I have no clue what causes it. But the repository is public:

https://github.com/wepublish/wepublish/tree/8e4198788c2d60aa5f03869a6fdf9bda2566b45f
The command needed to reproduce it: npm i && npx tsc -p ./apps/editor/tsconfig.app.json

If typescript version is set to ~4.6.0 everything works. If typescript is set to 4.7 or above, it fails

💻 Code

// We can quickly address your report if:
//  - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!
//  - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.
//  - The incorrectness of the behavior is readily apparent from reading the sample.
// Reports are slower to investigate if:
//  - We have to pare too much extraneous code.
//  - We have to clone a large repo and validate that the problem isn't elsewhere.
//  - The sample is confusing or doesn't clearly demonstrate what's wrong.

I haven't been able to produce a minimal reproduction.

🙁 Actual behavior

TSC crashes with an error thrown:

❯ npx tsc -p ./apps/editor/tsconfig.app.json
/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:98439
                throw e;
                ^

TypeError: Cannot read properties of undefined (reading 'get')
    at getTypeAliasInstantiation (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:50531:54)
    at createMarkerType (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:56512:17)
    at _loop_23 (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:56477:45)
    at getVariancesWorker (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:56498:21)
    at getVariances (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:56455:17)
    at structuredTypeRelatedToWorker (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:55675:41)
    at structuredTypeRelatedTo (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:55305:30)
    at recursiveTypeRelatedTo (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:55274:30)
    at isRelatedTo (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:54853:25)
    at isRelatedToWorker (/Users/itrulia/Documents/wepublish/node_modules/typescript/lib/tsc.js:54773:24)

🙂 Expected behavior

TypeScript does not crash and returns the relevant errors

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions