-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
reuse TS code templates for ES6/ES7 #169
Comments
Are you saying we should, during creating a new project, invoke the TS compiler to compile TS code into ES2015 in order to get the source code that we create into a Babel project? |
No, not when the developer is creating a new project, but when building aurelia-cli project. That is what I had in mind - makes more sense to me ;) |
Ah. Interesting. I'll think about it. Currently there isn't a build process for the cli, which is kind of nice. |
I think this is a good idea...however, I don't think it will work 100% since TS requires using a different import syntax with NodeJS than Babel does. Maybe Babel can support the same syntax though? If so, I would be interested in trying this out. It would be nice not to have to write and maintain two versions of everything. Would you be interested in investigating further and possibly sending a PR for the build task? @atsu85 |
I'm glad to hear it, did You consider reopening this issue? Actually I'm surprised, that at this point where skeleton-typescript still uses js instead of ts for building, You are attempting to write gulp tasks also in TypeScript :)
Looks like Babel supports the same syntax (
I'm surprised (maybe based on my incomplete understanding of ES6 modules), that Babel even works with that syntax (with that module), because as I understand this line: So if gulp-changed typings would contain |
I think it makes it work for compatibility purposes...but perhaps the TS syntax is actually correct. I just need to try it out and see if switching the babel version to that works. If so, we can probably take the approach you recommend. I'll report back soon. |
So far it still seems to me, that this is standard ES6 module import syntax, and not specific to TS |
I don't know why i didn't think about it before, when i wrote
but probably "transform-flow-strip-types" Babel plugin would do just what is desired here (remove TypeScript type info, but leave everything else, like ES7 decorators and class declarations there). But I haven't tested it, so I might have guessed incorrectly ;) |
Bingo! That's probably the best fit. I didn't think of it either :) |
Just in case - I don't know if this TS flag helps? microsoft/TypeScript#2901 Transpile using typescript to es2016 and use that flag? |
that removes extend and öhm decorators or something. would need to provide those helpers oneself |
I think that the correct flag is allowSyntheticDefaultImports. It worked for me with i18n related issue. |
@jwx this one is for you (-: |
Most ts/es6 template files are merged in current skeleton. Only those with too much differences are kept as two files. |
@EisenbergEffect, I noticed, that code templates are duplicated for both TypeScript and ES6/ES7 versions of the generated source code.
I'm wondering, if it is worth writing both TypeScript and ES6/ES7 versions of each class. Ideally ES6/ES7 should be generated from TypeScript. I guess You have considered it? Probably TypeScript compiler can't be used to only strip the type annotations (that might be what is desired here) so probably some other tool could be used instead? TypeScript compiler removes type annotations, but additionally:
__decorate(...)
What are Your thoughts?
The text was updated successfully, but these errors were encountered: