5 ms·
Yes, it is. Compiling TS just removes type annotations; the compilation output (.js) is as readable as your original .ts. It has the same structure, same indent
by nothrabannosir 11y ago
Yes, it is. Compiling TS just removes type annotations; the compilation output (.js) is as readable as your original .ts. It has the same structure, same indentation, same variable names, same whitespace, same comments, same everything. This also makes debugging the code in the browser very easy.
TS does not add any semantic features, it only adds type annotations. Which it checks at compile time, and then removes. That's it.
Want to switch away from TS? Compile all your .ts files, save the .js, check that into your repo and continue from there.
(As other commenters sort-of pointed out: you will need to keep Babel in your pipeline.)
- agumonkey 11y agoInteresting, I never 'considered' that. It's basically a thin typechecker linguistic layer. A variant of gradual typing.
- Roboprog 11y agoThanks for the concrete description. Can I still use dynamic constructs such as string subscripts to associative arrays and code generation via eval()?
- nothrabannosir 11y agoYou mean in TS? Yes. ∀ x: I can do x in JS → I can do x in TS But, let's assume for a second that you couldn't: this thread is about TS being future-proof. I.e.: ∃ x: I can do x in TS & I cannot do x in JS? No, false. This implies TS = JS. And that's the point: semantically, TS = JS.
- Roboprog 11y agoOK, that's a good start. Is there a tool analogous to JSDoc for TypeScript that gathers the same docs without repeating the type info already in the code?
- elisee 11y agohttp://typedoc.io/ http://typedoc.io/ might be what you're looking for.
- Roboprog 11y agoThanks. Also, some informative samples of what TypeScript itself looks like. https://github.com/sebastian-lenz/typedoc/blob/master/src/lib/application.ts https://github.com/sebastian-lenz/typedoc/blob/master/src/li...