Skip to content
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

Assertion violation: undefined relativeSpecifiers on Object.getModuleSpecifiers #42785

Closed
DanielRosenwasser opened this issue Feb 13, 2021 · 15 comments · Fixed by #43024
Closed
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@DanielRosenwasser
Copy link
Member

From @dlannoye:

dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:91576
                    ts.Debug.checkDefined(relativeSpecifiers);
                             ^
Error: Debug Failure.
    at Object.getModuleSpecifiers (dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:91576:30)
    at getSpecifierForModuleSymbol (dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:39998:62)
    at dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:39874:39
    at Array.map (<anonymous>)
    at getSymbolChain (dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:39872:58)
    at lookupSymbolChainWorker (dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:39858:51)
    at lookupSymbolChain (dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:39852:24)
    at symbolToTypeNode (dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:40005:29)
    at typeToTypeNodeHelper (dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:39150:28)
    at mapToTypeNodes (dependencies_path\[email protected]\node_modules\typescript\lib\tsc.js:39671:40)

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output labels Feb 13, 2021
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.2.2 milestone Feb 13, 2021
@DanielRosenwasser DanielRosenwasser added the Needs Investigation This issue needs a team member to investigate its status. label Feb 13, 2021
@btakita
Copy link

btakita commented Feb 23, 2021

I'm getting a similar error:

/patheu/typescript/lib/tsc.js:91587
                    ts.Debug.checkDefined(relativeSpecifiers);
                             ^
Error: Debug Failure.
    at Object.getModuleSpecifiers (/path/node_modules/typescript/lib/tsc.js:91587:30)
    at getSpecifierForModuleSymbol (/path/node_modules/typescript/lib/tsc.js:39998:62)
    at /path/node_modules/typescript/lib/tsc.js:39874:39
    at Array.map (<anonymous>)
    at getSymbolChain (/path/node_modules/typescript/lib/tsc.js:39872:58)
    at lookupSymbolChainWorker (/path/node_modules/typescript/lib/tsc.js:39858:51)
    at lookupSymbolChain (/path/node_modules/typescript/lib/tsc.js:39852:24)
    at symbolToTypeNode (/path/node_modules/typescript/lib/tsc.js:40005:29)
    at typeReferenceToTypeNode (/path/node_modules/typescript/lib/tsc.js:39463:40)
    at typeToTypeNodeHelper (/path/node_modules/typescript/lib/tsc.js:39155:95)

@btakita
Copy link

btakita commented Feb 24, 2021

This seems to be related to type inference; as the solution to this crash is to explicitly declare the type of a const though I'm not able to reproduce the exact cause.

@07akioni
Copy link

07akioni commented Feb 24, 2021

This seems to be related to type inference; as the solution to this crash is to explicitly declare the type of a const though I'm not able to reproduce the exact cause.

I'm facing the same problem (only in ts 4.2):

...
// got error
export const SsrContext = defineComponent({
...
// pass
export const SsrContext: ReturnType<typeof defineComponent> = defineComponent({
...

@flybayer
Copy link

I'm having the same error, and I have a small reproduction repo: https://github.com/flybayer/tsc-broken (boilerplate for a new Blitz app)

  1. git clone [email protected]:flybayer/tsc-broken.git
  2. cd tsc-broken
  3. yarn
  4. yarn tsc

Related: #42773

@dlannoye
Copy link
Member

For my projects that were reproducing this I tracked it back to a regression introduced by #42095 .

I was able to get my projects building without the crash by reverting a single line in the PR that was doing extra filtering on the return of forEachFileNameOfModule in src/compiler/moduleSpecifiers.ts.

I am not sure if this is a complete fix and how it might interact with the desired behavior introduced by #42095.

@dylanvorster
Copy link

have had to rollback to "typescript": "^4.1.5",. @dlannoye any chance you can open a PR?

@andrewbranch
Copy link
Member

@flybayer I can’t reproduce with your repo. I get a few checker errors but no crash:

❯ yarn tsc
yarn run v1.22.4
$ /System/Volumes/Data/Developer/microsoft/eg/tsc-broken/node_modules/.bin/tsc
app/auth/mutations/forgotPassword.test.ts:12:3 - error TS2698: Spread types may only be created from object types.

12   ...jest.requireActual("blitz")!,
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

db/index.ts:2:10 - error TS2305: Module '"@prisma/client"' has no exported member 'PrismaClient'.

2 import { PrismaClient } from "@prisma/client"
           ~~~~~~~~~~~~

types.ts:3:10 - error TS2614: Module '"db"' has no exported member 'User'. Did you mean to use 'import User from "db"' instead?

3 import { User } from "db"
           ~~~~


Found 3 errors.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@dlannoye (or actually anyone else who has seen this error), are you using pnpm or some other system that puts modules in a hidden folder (starting with .) inside node_modules? The line you reverted to fix your problem is supposed to filter out invalid module specifiers, and the crash means you were left with no valid module specifiers after the filtering. But if you’re not using pnpm, I’m very confused as to what was getting filtered out in the first place. If anyone can provide a small reproduction of this bug, that would be very helpful.

@flybayer
Copy link

flybayer commented Mar 1, 2021

@andrewbranch run yarn blitz prisma generate to fix those type errors, and then tsc should crash. That prisma command is supposed to run automatically. It generates code and typedefs at node_modules/.prisma.

@andrewbranch
Copy link
Member

Ah, yep, the .prisma is the culprit there. Are you supposed to be able to import from ".prisma"? We assume that anything in a dotted folder in node_modules is a temporary path and should be ignored.

@flybayer
Copy link

flybayer commented Mar 1, 2021

@andrewbranch no you import from @prisma/client, which internally imports from .prisma

@andrewbranch andrewbranch assigned andrewbranch and unassigned rbuckton Mar 1, 2021
@dlannoye
Copy link
Member

dlannoye commented Mar 1, 2021

Yes, I am using PNPM in my repository. The issue no longer reproduces if I clean and using npm instead for this project.

@MaikuMori
Copy link

I have the same problem using yarn, also with prisma installed. I haven't tried to switch to npm.

@dlannoye
Copy link
Member

dlannoye commented Mar 2, 2021

Just tested my codebase with "typescript": "4.3.0-dev.20210302" and can confirm that the assertion no longer reproduces. Thanks for the fix!

@sbalay
Copy link

sbalay commented Mar 3, 2021

@andrewbranch do you know if this fix will be released soon?

@andrewbranch
Copy link
Member

Yes; it will (4.2.3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet