ember-cli-babel icon indicating copy to clipboard operation
ember-cli-babel copied to clipboard

auto-strip typescript

Open stefanpenner opened this issue 6 years ago • 8 comments

Should we simply auto-strip typescript by default? This would mitigate the need for typescript'd code to be prebuilt built.

cc @rwjblue / @chriskrycho

stefanpenner avatar Feb 21 '19 01:02 stefanpenner

Huh, interesting thought. So then the work of ember-cli-typescript and similar would just be providing the build/publish hooks to let people generate their type definitions (as desired) and injecting build failures if they so desired. 🤔 cc. @dfreeman @dwickern @mike-north

chriskrycho avatar Feb 21 '19 14:02 chriskrycho

What do you mean RE: auto-stripping? Remove from the build without compiling from .ts -> .js? How would that actually work?

rwjblue avatar Feb 21 '19 14:02 rwjblue

No, just doing the "compile" step for TS as Babel understands it – just stripping the types.

chriskrycho avatar Feb 21 '19 14:02 chriskrycho

@rwjblue Babel/swc support a non/type checking ts -> JavaScript transform, this transform being enabled is what I meant by auto-stripping

stefanpenner avatar Feb 21 '19 14:02 stefanpenner

This is effectively what ember-cli-typescript@2 is already doing today (though granted you have to opt into it by adding e-c-ts as a dependency).

The prepublish build step we have there is for generating declaration files in a location discoverable by tsc, since the actual sources in addon/**/*.ts won't have the addon/ segment in their ultimate import path.

dfreeman avatar Feb 22 '19 13:02 dfreeman

@dfreeman ya, I wonder though if we should consider pushing it down the stack to reduce maintenance/keep stuff in sync, enable this by default. That may allow e-c-ts to focus on the typechecking side of things

stefanpenner avatar Feb 22 '19 14:02 stefanpenner

It's an interesting idea. Today adding the plugin is pretty trivial for us to do, but in the future (e.g. if we start getting things like swc in the mix) I can definitely see the appeal of not having to manage the transpilation setup ourselves in ember-cli-typescript.

On the other hand, there's a maintenance/sync problem on the TypeScript language side as well. @babel/plugin-transform-typescript isn't the only thing you necessarily need to include to get full TypeScript support. Today you also have to add the class properties plugin (and potentially decorators), but the set of needed plugins for full coverage will be a moving target if TS adopts proposals before they hit stage 4 and get handled automatically by present-env. Is that something we'd want to take on handling here?

dfreeman avatar Feb 22 '19 15:02 dfreeman

FWIW, we have made a bit of progress here. Currently, ember-cli-babel will detect if ember-cli-typescript is present (and at the right minimum version) and add the babel plugins itself.

That was added in #314.

rwjblue avatar May 29 '20 13:05 rwjblue