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

Imported types are converted into strings in literal expression #1716

Closed
cengels opened this issue Jul 4, 2023 · 0 comments · Fixed by #1717
Closed

Imported types are converted into strings in literal expression #1716

cengels opened this issue Jul 4, 2023 · 0 comments · Fixed by #1717

Comments

@cengels
Copy link
Contributor

cengels commented Jul 4, 2023

The following code:

// types.ts
export type MyType = 'one' | 'two' | 'three';

// interface.ts
import { MyType } from './types';

export interface MyObject {
    value: `_${MyType}`;
}

unexpectedly results in a schema where value is simply { "type": "string" } instead of

{
    "enum": [
      "_one",
      "_two",
      "_three"
    ],
    "type": "string"
  }
}

This seems to happen because extractLiterals() currently only considers AliasTypes, not DefinitionTypes.

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

Successfully merging a pull request may close this issue.

1 participant