generator icon indicating copy to clipboard operation
generator copied to clipboard

¿TypeScript support?

Open sant123 opened this issue 9 years ago • 10 comments

Hi, ¿what would you think about TypeScript in the generator? People would generate robust applications with full rich intellisense and more!

Let me now in order to make a pull request.

Thank you!

sant123 avatar Jul 17 '16 05:07 sant123

Can you explain what adding TypeScript support would look like? I guess you can make a PR if that is easier than explaining the idea, though I'm not saying we'd accept the PR, since I don't understand what it would entail.

dougwilson avatar Oct 06 '16 22:10 dougwilson

Hi @dougwilson, the reason is for a better Javascript writing. I mean, with types support you know what you are writing, you can get intellisense from request and response objects, also for Router object, and so on. I'm not saying replace the Javascript generator, because not all like Typescript; but in other hand other people do, and them (even me) would start a express project with Typescript out of the box.

sant123 avatar Oct 07 '16 12:10 sant123

Hi @sant123 , sorry, I guess I didn't ask right :) So what I was asking was what the code would look like to add the TypeScript support here. I don't really have any TypeScript experience, so wouldn't be able to implement this functionality myself, so I'm not sure how to really proceed even if we wanted this.

dougwilson avatar Oct 13 '16 02:10 dougwilson

Not sure if it's what @sant123 was trying to say, but perhaps he meant a TypeScript-ified version of the presently generated files? I read a blog post here: http://brianflove.com/2016/11/08/typescript-2-express-node/ where the author essentially recreates the seed project but with classes and typing.

I know I would be interested in something like that - the context for me is coming from an Angular front end world and looking for a server to back it. Staying with TypeScript has a lot of appeal for back end development, so a generator that provides the basic wiring (typings and a compile step I guess?) would be cool.

tobymurray avatar Feb 17 '17 04:02 tobymurray

Supporting TypeScript basically means changing the generated files from plain JavaScript to TypeScript. You can see an example for an Express-TypeScript seed here: https://github.com/lokeshthegenius/express-typescript-gulp-seed

The following steps should be made:

  • Change the template files to match TypeScript syntax (add types to functions, ES2015 modules and etc)

  • Add typecsript to devDependencies in the package.json, and change the npm start script

  • Add --typescript argument that will use the above templates instead of the regular JS templates

Many people use TypeScript nowadays, so in my opinion that's kind of a must have feature.

bluzi avatar Jul 18 '17 14:07 bluzi

As well as the above an agreed upon tslint.json and tsconfig.json would be necessary. So some thought regarding Typescript standards for express is also required.

ghost avatar Oct 16 '17 15:10 ghost

Well, TypeScript is getting more and more popular, and I think it will be a nice addition to the generator.

@dougwilson, will you accept a PR?

bluzi avatar Oct 16 '17 15:10 bluzi

Any info about this topic?

FlopiVG avatar Jul 11 '18 07:07 FlopiVG

👍 This would be really nice, somebody have something?

rromanv avatar Oct 26 '18 07:10 rromanv

So, with this problem, I came up with a solution, create-ts-api. here the github repo and link to npm registry.

Feel free to raise an issue for more improvements...

bineetNaidu avatar Aug 01 '21 15:08 bineetNaidu