Skip to content

Conversation

@IllusionMH
Copy link
Contributor

Fixes #30962

@IllusionMH IllusionMH force-pushed the enum-template-literals-30962 branch from fdeb759 to e1b6696 Compare April 20, 2019 11:32
@IllusionMH IllusionMH force-pushed the enum-template-literals-30962 branch from e1b6696 to 1b8eab5 Compare April 23, 2019 22:16
@IllusionMH
Copy link
Contributor Author

One small question:
If this one is accepted do I need to update Handbook - Enums section?
It has line "a literal enum expression (basically a string literal or a numeric literal)". Should it include somethins like "basically a string literal, a numeric literal, or a template literal without placeholders" or it is unnecessary detail/incorrect statement?

@RyanCavanaugh
Copy link
Member

@ahejlsberg just wanted to get a 👍 from you on this one before proceeding

@ahejlsberg
Copy link
Member

You made this comment in the issue:

NoSubstitutionTemplateLiteral should be as good as StringLiteral anywhere here IMO

I agree, but this PR narrowly handles string literals in enum initializers. There are multiple other places in the checker where we look for StringLiteral but not NoSubstitutionTemplateLiteral. It's my opinion we should do all of them or none of them.

@weswigham
Copy link
Member

It's my opinion we should do all of them or none of them.

Except ES6 imports. Because per spec they aren't allowed there. :(

@IllusionMH
Copy link
Contributor Author

IllusionMH commented Apr 26, 2019

Oh, I was working in scope of initial issue so this PR only supports enums.
If there are no objections - I will prepare new PR to cover other places and replace this PR.

Just to clarify scope of expected PR:

  1. Updates only to checker

  2. Add support for NoSubstitutionTemplateLiteral where StringLiteral is supported

  3. Do not add TemplateExpressions at this point

  4. Exceptions:

    ES6 imports. Because per spec they aren't allowed there.

    Which is already "String literal expected." error.

Is it correct?

@RyanCavanaugh RyanCavanaugh self-assigned this Apr 30, 2019
@IllusionMH
Copy link
Contributor Author

I'm finishing my investigation of places where support for NoSubstitutionTemplateLiteral can be added.
Should I create separate issue with list of changes for discussion or draft PR with detailed description would be enough?

@arcanis
Copy link

arcanis commented May 21, 2019

Is there a blocker on this issue I could help with?

@IllusionMH
Copy link
Contributor Author

I've prepared list of places that have different behavior for template literals and regular strings.
Hope that scope described in #31548 will be approved and I'll send new PR (will include this changes too) this week.

@IllusionMH
Copy link
Contributor Author

Closing this one in favor of #32064

@IllusionMH IllusionMH closed this Jun 24, 2019
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backtick literals in enumerations

6 participants