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

Feature request: Add Node.js integration tutorial #12964

Closed
olalonde opened this issue Dec 15, 2016 · 10 comments
Closed

Feature request: Add Node.js integration tutorial #12964

olalonde opened this issue Dec 15, 2016 · 10 comments
Assignees
Labels
Docs The issue relates to how you learn TypeScript

Comments

@olalonde
Copy link

I wanted to try typescript in a Node.js environment but documentation on https://www.typescriptlang.org/docs/tutorial.html is lacking. Maybe add a "Node.js" tutorial in the "Tutorial" submenu.

@cwebster2
Copy link

Can you clarify what exactly you are looking for? The link you provided is within a Node.js environment. It instructs you to install typescript via npm and then has you call tsc which will be located in you node_modules/,bin/tsc. To me, that is a Node.js environment, managed via npm so I don't really follow what you want more than that.

@olalonde
Copy link
Author

olalonde commented Dec 16, 2016

All the tutorials seem to be targeted at developers writing browser side JavaScript. I'd like a tutorial on setting up an Express app for example. I believe there are some compiler options like target that would be especially helpful for Node.js code (e.g. you probably don't want to unnecessarily compile down to ES5 if you're using a recent version of Node). You also might want to use something like ts-node to run your tests. You also might want to run npm install @types/node --save. I have no idea to be honest as I've not used typescript yet.

Maybe just linking to a few open source libraries that use TypeScript on GitHub would help immensely. As a comparison, the "getting setup" guides for Babel feels more complete: http://babeljs.io/docs/setup/

@DanielRosenwasser DanielRosenwasser added the Docs The issue relates to how you learn TypeScript label Dec 17, 2016
@DanielRosenwasser
Copy link
Member

I think this is reasonable. In general I'd like for us to have a decent Express tutorial, or something along those lines.

@elithrar
Copy link

To add to this (to whomever picks this up), some roadblocks I hit when converting an Node+ES6 project to Node+TS2.2:

  • imports/require. TypeScript is stricter about namespaces (for lack of a better term) and importing from other modules - e.g. what is otherwise acceptable in ES5/ES6 is not in TypeScript.
// actions.js

let actions = new Map() // src/actions.ts(5,5): error TS2451: Cannot redeclare block-scoped variable 'actions'.
...
module.exports = { actions }
// index.js
const actions = require("./actions") // src/index.ts(3,7): error TS2451: Cannot redeclare block-scoped variable 'actions'.

...
if (actions.has(key)) { ... }
  • Setting up tsconfig.json for Node: a solid, concrete example and/or explanation of options - e.g. compilerOptions.target: es5 vs. es6 and moduleResolution: "node" and what they each mean.

A 2-3 module Express tutorial would be a solid base to start from.

@bowdenk7
Copy link

I'm working on one right now. Let me know if you're interested in reviewing and/or helping me make it better!

@elithrar
Copy link

elithrar commented Apr 12, 2017 via email

@bowdenk7
Copy link

bowdenk7 commented May 8, 2017

Sorry for the horribly slow response @elithrar... I lost track of this thread in my notifications >< https://github.com/bowdenk7/express-typescript-starter

@elithrar
Copy link

@bowdenk7 Hah! I also created a really simple starter (https://github.com/elithrar/node-typescript-starter) around the same time. Yours is definitely more complete, and definitely more useful if you're starting an Express app, whereas mine is a minimal as possible (e.g. just a base).

(nice work)

@bowdenk7
Copy link

Nice! We should compare notes. I see you have ts-node in your devDependencies. How are you using that and what are your thoughts on the performance?

@RyanCavanaugh
Copy link
Member

We're trying to scope down the TS documentation to "stuff only we know how to document". I think this is broadly covered by other resources on the internet by now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs The issue relates to how you learn TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants