-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Transpile all .ts files #5898
Transpile all .ts files #5898
Conversation
|
How does cross-compiling with TypeScript work when tsc has to have every file in the project to compile a file? (i.e. TypeScript by-design isn't a simple 1:1 mapping unlike Babel or CoffeeScript, to compile input file X, you need the type definitions of all the types it uses including the other files in the project). |
Not essentially. Consider
var foo = 123;
export = foo;
import foo = require('./foo');
console.log(foo); // 123 Each file can be compiled on its own. However file I have semantic validation disabled by passing |
|
Also, call sites in TypeScript do not rely on source type information. So absence of type information does not change the emit. This is by design. |
|
@paulcbetts I've just pushed a multifile demo : basarat/atom-typescript-test@1dfe56b The files are compiled separately (in the absence of type information about the other files) and still work : |
|
@basarat Aha, now it makes sense. It'd be cool to start making a more generalized framework for loading cross-compilers, because they're going to start hurting startup time and require perf (and hurting require perf is pretty bad, though in the TypeScript case it's a very quick "Does file end in .ts" check) |
In general hurting require perf even a little is gonna run counter to this goal (and the 1.0 goal of reducing startup time) in a big way and will need the most convincing of justifications: electron/electron#169 |
|
@thedaniel I think this can probably be pretty easily done, since these require hooks are so easy to register. We just put it off until we find typescript files |
|
Also I couldn't get sourcemaps to work because of fancy JS wrapping : TypeStrong/atom-typescript#156 (comment) Note: I can get them to work with more custom code but I'd rather atom do it for me + any other TS package authors. |
|
@basarat So is this something that is ready to review? Or did you still have any planned changes left? |
|
Could you add some tests for this as well? You can model them after the babel specs. |
|
@kevinsawicki was ready for review. I'll add the tests tonight and ping you. |
|
@kevinsawicki ready for review. Also updated (and marked as completed) the todo list ❤️ |
spec/typescript-spec.coffee
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these should be needed since the TypeScript addition shouldn't have any deprecations to start with, unless I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't needed. Removed. Sorry.
|
@kevinsawicki ready for review again. Did:
Also I'm now using |
package.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this require used anymore now that typescript-simple is used?
|
@kevinsawicki done:
|
|
Thanks for making all these updates, this feels like it is getting really close. One thing I thought of though was this should be added to the compile-cache helper class that is called directly by apm: Line 26 in 11a5b71
And also to atom/spec/compile-cache-spec.coffee Line 10 in 11a5b71
|
|
|
|
@kevinsawicki done:
|
|
Thanks @basarat, this looks really nice. Just chiming in, as @basarat mentioned TypeScript errors do not block the generation of JavaScript. we have always thought of the type check errors as warnings that the compiler provides the developer at design time but do not block the rest of the tool chain. In general TypeScript does not have emit that depends on global program optimizations, we have steered away from these for the most part. So in Atom's context it should be safe to use typescript as a single file transpiler without loosing correctness. For completeness sake, there are We would like to also add new API for single file transpilation, making typescript-simple's life much simpler (no pun intended :)); and to ensure this scenario is well supported in the future. It is really nice to see TypeScript plugins in Atom. can not wait to try writing one myself! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to target ES5 vs. ES6 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Typescript supports a superset of ES6 futures supported by IO.js
If Typescript spits out ES6 it might not run natively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay, thanks for the details 👍
|
Awesome, thanks so much for adding this 🚢 |
|
❤️ can't thank you enough for this. |
Awesome! I'm waiting. |
…ary noise Hopefully we will move to pure TS modules soon as atom/atom#5898 is merged

This is similar to #5299
Provide TypeScript support to ease package development.
Motivation
.jsfiles when creating packages using TypeScriptSample
You can see a sample package here : https://github.com/basarat/atom-typescript-test


same as other PR
TODO:
/cc @vvakame @csnover