Skip to content
This repository was archived by the owner on Jun 15, 2020. It is now read-only.

Enums should go in a .ts file, not .d.ts #4

Closed
brent-williams opened this issue Oct 8, 2015 · 5 comments
Closed

Enums should go in a .ts file, not .d.ts #4

brent-williams opened this issue Oct 8, 2015 · 5 comments

Comments

@brent-williams
Copy link

Current behaviour puts enum definitions in .d.ts. With TS 1.6 this can result in the definitions not making their way into any .js. Similar issue with similar tool (https://bitbucket.org/LukasKabrt/typelite/issues/17/enums-should-go-in-a-ts-file-not-dts) had them moving enums from .d.ts to a .ts. Can/should same be done in Proto2TypeScript?

@fungiboletus
Copy link
Member

The current system doesn't generate .ts file, only definitions. So I am not sure if we should keep the enum system if TS 1.6 requires specific code.

@brent-williams
Copy link
Author

Problem may exist in TS 1.4/5 as well. Solution I implemented locally is just quick-and-dirty code to cut enums from end of .d.ts (as output from Proto2TypeScript) and pipe them into a .ts included in the project. Also replaced "export enum" with "export const enum". All seems to work fine with these two changes. Minor change and should be backwards compatible to TS < 1.6 as well.

@DouglasHeriot
Copy link
Contributor

I ran into this. Started having a go at fixing it. Added a command-line option to make it write output to separate .ts and .d.ts files (instead of standard output). Planning to have it run through twice, with separate templates.
Didn’t finish it, as I had more important work to be doing. Might get back to it next time I need an enum…

@tamird
Copy link
Contributor

tamird commented May 10, 2016

@DouglasHeriot is that work available somewhere? We're seeing this issue in cockroachdb/cockroach#6616.

@DouglasHeriot
Copy link
Contributor

Ok – just pushed it to branch enums in my repo here: https://github.com/DouglasHeriot/Proto2TypeScript/tree/enums

Haven’t looked at it for a while. I think I set up the basic stuff to have it run through the templates twice and output 2 separate files. Just need to actually write a separate set of templates that will only output the enums. (Curently, I think both output files are the same/similar – not correct at all)

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

No branches or pull requests

4 participants