-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Support for ES6 Templates #960
Conversation
Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json
Still need to implement some error recovery and add tests.
These tests still need to be fixed.
@@ -5932,6 +5939,12 @@ module ts { | |||
return getUnionType([type1, type2]); | |||
} | |||
|
|||
function checkTemplateExpression(node: TemplateExpression): void { | |||
forEach((<TemplateExpression>node).templateSpans, templateSpan => { |
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.
Explain why this is correct. I believe it's because we rewrite this to string addition, and string addition allows the other side to be of any type. So we don't need to check for things like void types, etc. But it would be good to comment this bit.
"Do we want to accept simple (non-substitution) templates in places we accept string literals (i.e. module names, overloading on string constants, etc.)? On one hand, it would seem more consistent with the rest of our language, but ECMAScript 6 does not accept them in property names." I would say no. I'm not sure we have a reason to be more lenient than ES6. |
@JsonFreeman I agree; what about indexing? |
I think we can type an index expression with literal, yes. |
Conflicts: src/compiler/checker.ts src/services/services.ts
Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json src/compiler/types.ts src/services/utilities.ts
66cb969
to
35cf95c
Compare
Support for ES6 Templates
@RyanCavanaugh excuse me. please add |
I just noticed that this ES6 feature is still a proposal, so why implement it already? Not that it isn't great and useful, just wondering why focusing on things that are still |
It's actually pretty much nailed down, and it's very unlikely that it will be removed/modified drastically. If anything does change, we'll be very mindful in addressing that. =) |
Ok, nice then, it's a nice feature btw, looking forward for 1.4. :) |
Hi there, I realize that this is on the Roadmap for 1.4. I'm curious though if we might see it sooner as perhaps an experimental option. My team and I would certainly love to start using this sooner rather than later to clean up our code :-) Cheers! |
Hey @topherfangio, glad to hear you're enthusiastic about this feature. If you're dying to try it out, you can clone our repo and use our |
This pull request is meant to add support for ECMAScript 6 templates and address suggestion #13.
Right now this branch supports:
Things that will be done in a separate commit:
Questions worth asking: