-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Provide TypeScript compilation support when using ember-cli-typescript@4 or higher. #314
Provide TypeScript compilation support when using ember-cli-typescript@4 or higher. #314
Conversation
The floating deps job has also failed recently for a docs-only PR. ¯\_(ツ)_/¯ |
also s/_shouldIncludeTypeScriptPlugins/_shouldHandleTypeScript/ Co-authored-by: Dan Freeman <[email protected]>
Co-authored-by: Dan Freeman <[email protected]>
#315 should fix the floating deps tests. |
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.
Thanks for working on this! I did a partial review with some inline comments, but didn't fully complete review. I'll try to poke at it a bit more this afternoon.
index.js
Outdated
if (typeof emberCLIBabelConfig.enableTypeScriptTransforms === 'boolean') { | ||
return emberCLIBabelConfig.enableTypeScriptTransforms; | ||
} |
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.
This is great, it allows for a really nice escape hatch when our autodetection may fail (which AFAICT shouldn't happen, but it is still nice to be prepared).
Can you add this to the documentation in the README?
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.
There are also people wishing to use TypeScript without integrated type-checking, which this option would enable (by not having to install ember-cli-typescript
just to get TypeScript transpilation).
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 also documented the automatic behavior and incompatibility of this option with e-c-ts < 4.0.
index.js
Outdated
if (this.parent === this.project) { | ||
this.project.ui.writeWarnLine(`${ | ||
this._parentName() | ||
} has added the optional chaining plugin to its build, but ember-cli-babel provides this by default now when ember-cli-typescript >= 4.0 and typescript >= 3.7 are installed! You can remove the transform, or the addon that provided it.`); |
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.
Just to double check, this is added by default because TypeScript requires it? Also, how do you know that typescript >= 3.7 is being used (does e-c-ts bring a minimum of [email protected]?)?
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.
Side note, we may want to make a more official policy to include things like this in the future (e.g. "stage-3 proposals are added by default"), not sure but that would probably require an RFC.
What do you think @pzuraq?
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, this is because these features are part of TS >= 3.7. The reason these have to be added unconditionally is because we don't know the TypeScript version an addon might have used.
ff592d3
to
5fb2aa0
Compare
@rwjblue one thing the typed-ember folks had talked about as part of our v4 release was explicitly excluding Do you have thoughts on how we might best accomplish that? |
@dfreeman - When running our |
Tweaking this To be something like: transpileTree(inputTree, config) {
let description = `000${++count}`.slice(-3);
let postDebugTree = this._debugTree(inputTree, `${description}:input`);
let options = this.buildBabelOptions(config);
let output;
if (this._shouldDoNothing(options)) {
output = postDebugTree;
} else {
let BabelTranspiler = require('broccoli-babel-transpiler');
let transpilationInput = postDebugTree;
if (this._shouldCompileTypescriptOrWhateverTheMethodIsCalled()) {
transpilationInput = this._debugTree(new Funnel(postDebugTree, { excludes: ['**/*.d.ts']}), `${description}:filtered-input`);
}
output = new BabelTranspiler(transpilationInput, options);
}
return this._debugTree(output, `${description}:output`);
}, |
👍 Thanks, that makes sense! I wasn't sure if there was a cleverer way than just funneling the input, but I guess that's exactly what we'd be doing if we implemented outside of ember-cli-babel anyway |
This reverts commit 21de796.
@rwjblue @dfreeman When I saw this, I was hoping there was a way to filter out |
[email protected] has been released, so this is now ready to be included in an |
Don't emit modules for .d.ts files
0a85eee
to
45e006f
Compare
As of 7.8.0, @babel/preset-env enables optional-chaining and nullish-coalescing by default.
45e006f
to
4ab55d1
Compare
Since |
This is based on a conversation between some of the
ember-cli-typescript
maintainers (including @dfreeman and @chriskrycho) and @rwjblue. Theember-cli-typescript
side of this is happening in typed-ember/ember-cli-typescript#1018.This moves management of
@babel/plugin-transform-typescript
toember-cli-babel
whenember-cli-typescript >= 4.0.0-alpha.1
is installed in the parent. It also adds@babel/plugin-proposal-optional-chaining
and@babel/plugin-proposal-nullish-coalescing-operator
whenember-cli-typescript >= 4.0.0-alpha.1
is installed because these are standard features in TypeScript >= 3.7.0 (and we can't add these conditionally because we can't be sure about the TypeScript version used in addons).See typed-ember/ember-cli-typescript#1018 for the release plan.