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

TS 5.0: Query type failed to get a symbol for typeof TypeEmitter<T, TOptions> #2220

Closed
timotheeguerin opened this issue Apr 6, 2023 · 2 comments
Labels
bug Functionality does not match expectation
Milestone

Comments

@timotheeguerin
Copy link

timotheeguerin commented Apr 6, 2023

Search terms

typescript5.0, query failed

Expected Behavior

Type should be extracted correctly or at least not crash

Actual Behavior

AssertionError [ERR_ASSERTION]: Query type failed to get a symbol for: typeof TypeEmitter<T, TOptions>. This is a bug.
    at Object.convertType (/Users/timotheeguerin/.npm/_npx/dafcb7cdaad6ed61/node_modules/typedoc/dist/lib/converter/types.js:394:30)
    at convertType (/Users/timotheeguerin/.npm/_npx/dafcb7cdaad6ed61/node_modules/typedoc/dist/lib/converter/types.js:105:34)
    at Converter.convertType (/Users/timotheeguerin/.npm/_npx/dafcb7cdaad6ed61/node_modules/typedoc/dist/lib/converter/converter.js:93:40)
    at /Users/timotheeguerin/.npm/_npx/dafcb7cdaad6ed61/node_modules/typedoc/dist/lib/converter/factories/signature.js:89:44
    at Array.map (<anonymous>)
    at convertParameters (/Users/timotheeguerin/.npm/_npx/dafcb7cdaad6ed61/node_modules/typedoc/dist/lib/converter/factories/signature.js:70:23)
    at createSignature (/Users/timotheeguerin/.npm/_npx/dafcb7cdaad6ed61/node_modules/typedoc/dist/lib/converter/factories/signature.js:39:25)
    at Object.convertFunctionOrMethod (/Users/timotheeguerin/.npm/_npx/dafcb7cdaad6ed61/node_modules/typedoc/dist/lib/converter/symbols.js:247:41)
    at convertSymbol (/Users/timotheeguerin/.npm/_npx/dafcb7cdaad6ed61/node_modules/typedoc/dist/lib/converter/symbols.js:135:41)
    at Converter.convertExports (/Users/timotheeguerin/.npm/_npx/dafcb7cdaad6ed61/node_modules/typedoc/dist/lib/converter/converter.js:201:41) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: undefined,
  expected: true,
  operator: '=='
}

Steps to reproduce the bug

Add the following code when using typescript 5.0(Not having an issue before)

export class TypeEmitter<T, TOptions extends object = Record<string, never>> {}

export function createAssetEmitter<T, TOptions extends object>(
  TypeEmitterClass: typeof TypeEmitter<T, TOptions>
): void {}

Repro PR: TypeStrong/typedoc-repros#28

Environment

  • Typedoc version: 0.23.28
  • TypeScript version: 5.0 (working before)
  • Node.js version: v18.8.0
  • OS: OSX
@timotheeguerin timotheeguerin added the bug Functionality does not match expectation label Apr 6, 2023
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 7, 2023

This appears to be because TS before 5.0 didn't preserve the query type when dealing with types (as you can see by pasting this into https://ts-ast-viewer.com/), so I never noticed before now that TS doesn't always give a symbol. I've asked in the compiler API channel of the TS discord if there's a better way of doing this.

@Gerrit0 Gerrit0 added this to the v0.24 milestone Apr 7, 2023
@timotheeguerin
Copy link
Author

Thanks for the quick turnaround!

@Gerrit0 Gerrit0 closed this as completed in 234899d Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants