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

ES6 or TypeScript with transpile? #1064

Closed
suntong opened this Issue Jan 21, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@suntong
Copy link
Contributor

suntong commented Jan 21, 2018

Just a simple noob question,

If I write wechaty module in TypeScript, and run it like this:

docker run -it --rm --volume="$(pwd)":/bot zixia/wechaty bot1.ts

Will there be any transpile going on before nodejs actually run it?

I'm a long time programmer but never did JavaScript programming before, so I'm assessing whether I should write my wechaty module in TypeScript, or just in plain ES6.

If TypeScript needs transpile, then would wechaty transpile it to ES5 or ES6?

Thanks!

@huan huan added the question label Jan 22, 2018

@huan

This comment has been minimized.

Copy link
Member

huan commented Jan 22, 2018

Hello @suntong ,

Frist question:

Will there be any transpile going on before nodejs actually run it?

When you run your bot1.ts directly by zixia/wechaty, indeed we use ts-node to run your bot1.ts, which will let you be able to run TypeScript directly(it do transpile transparently internal).

You can learn more about ts-node at https://www.npmjs.com/package/ts-node

Second question:

If TypeScript needs transpile, then would wechaty transpile it to ES5 or ES6?

We currently use ES6 in our ts-config.json settings.

However, if you want to publish an NPM module by yourself, I'll suggest you do transpile to ES6/ES5 by yourself.

See: http://ljn.io/posts/publishing-typescript-projects-with-npm/

Please feel free to let me know if you still have other questions.

@suntong

This comment has been minimized.

Copy link
Contributor Author

suntong commented Jan 22, 2018

Thanks for your detailed answer and references, @zixia!

@suntong suntong closed this Jan 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment