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

property valueClassBrand of type NNN is not assignable to string index type XXXX in declaration file (d.ts) #126

Open
sakari opened this issue Sep 7, 2020 · 0 comments

Comments

@sakari
Copy link
Collaborator

sakari commented Sep 7, 2020

oats generates a ts-ignore to the source file when the schema has object type with additionalFields: A where A is not any or unknown. This is because we use a phantom object property to brand types. The ts-ignore pragma circumvents typescript error about the field used for branding not matching the type of the string indexed field.

Sadly typescript does not keep the ts-ignore pragmas in the d.ts file it generates so the same type error happens when trying to use the generated code as a library. See microsoft/TypeScript#38628

The workaround to this is to postprocess the d.ts file and add the ignore back there. The index key name is always the same so finding it from the d.ts file should be easy.

If this becomes a major issue we could export some helpers to deal with this.

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

1 participant