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

Generation failing for custom utility type #1855

Open
countnazgul opened this issue Jan 23, 2024 · 1 comment
Open

Generation failing for custom utility type #1855

countnazgul opened this issue Jan 23, 2024 · 1 comment

Comments

@countnazgul
Copy link

For some reason generation is failing for the following:

type AtLeastOne<T, U = { [K in keyof T]: Pick<T, K> }> = Partial<T> &
  U[keyof U];

interface SomeInterface {
  props: AtLeastOne<{
    prop1: string[];
    prop2: string[];
    prop3: string[];
  }>;
}

with the following error:

Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'getId')
    at <anonymous> (C:\Dev\Temp\node_modules\ts-json-schema-generator\dist\src\Utils\nodeKey.js:43:57)
    at getKey (C:\Dev\Temp\node_modules\ts-json-schema-generator\dist\src\Utils\nodeKey.js:43:40)
    at getCacheKey (C:\Dev\Temp\node_modules\ts-json-schema-generator\dist\src\NodeParser.js:30:55)
    at createType (C:\Dev\Temp\node_modules\ts-json-schema-generator\dist\src\ChainNodeParser.js:25:41)

Have a look at the codesandbox example and ts playground

@ELigoP
Copy link

ELigoP commented Jan 31, 2024

I've got similar issue when using kind of A<T, U = something depending on T> and then referencing this as A<SomeType>. I hoped U will be inferred, but got this error instead. Had to go another way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants