Any way to generate Typescript `.d.ts` declaration files instead of `.ts`?
Closed this issue · 9 comments
Thanks in advance!
I guess not with the current setup, no. Can I ask a bit about the use case? Why is this necessary? Are you using any enums?
One of the use cases is that it allows the type definitions to be used in purely js
modules. Plus, it semantically makes sense to have all the type definitions of a project in type declaration (.d.ts
) files.
Yeah, I can see how that makes sense. What would you suggest in the case of enums? Should they be disallowed with this option?
That's a good point. Honestly I don't have enough information on this but maybe this could be a solution.
|
chaining for Enums is what I've seen done in other tooling like the graphql "codegen".
@karloluis I am not sure I follow. How do you use the pipe operator with enums?
Instead of typing enums as the enum Vals { value1, value2 }
it will instead be type Vals = 'value1' | 'value2'
Ah right. That's possible by setting enumStyle
to type
for unions. I was considering making this the default as I greatly prefer unions over enums, but enums have the one upside that items can have comments.
For future readers, you might not need this, TypeScript appears to be happy with packages that just do "types": "./dist/index.ts"
, index.ts
being generated by generateIndexFile
pre-render hook.