Skip to content

Allow template strings (with no interpolated expressions) to start off with literal types #16592

Description

I can't find the original issue (if there is one).

const c: "hello" = `hello`

Expected: No error.
Actual: Type 'string' is not assignable to type '"hello"'.

We should just allow people to use NoSubstitutionTemplates the way that they're allowed to use regular strings.

Activity

  1. added
    BugA bug in TypeScript
    Domain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefined
    SuggestionAn idea for TypeScript
    and removed
    BugA bug in TypeScript
    on Jun 16, 2017
  2. ericbf commented on Sep 5, 2017

    @ericbf
    Contributor

    This should also cover using NoSubstitutionTemplates as literal types as in #18109

  3. ericbf commented on Sep 13, 2017

    @ericbf
    Contributor

    Is there any progress being made on this?

    Andy (Andrewkraft) (@Andy-MS) the PR that referenced this issue didn't completely resolve the cases covered by using NoSubstitutionTemplates as literal types.

  4. ghost closed this as completedin #18452on Sep 14, 2017
  5. ghost added
    FixedA PR has been merged for this issue
    on Sep 14, 2017
  6. ghost removed on Sep 14, 2017
  7. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions