Skip to content
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

template literals fail to type check as string literals #17595

Closed
spoonscen opened this issue Aug 3, 2017 · 2 comments
Closed

template literals fail to type check as string literals #17595

spoonscen opened this issue Aug 3, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@spoonscen
Copy link

TypeScript Version: 2.4.0

Code

type Foo = 'lol'

const barr: Foo = `lol`
// Type 'string' is not assignable to type '"lol"'.

https://www.typescriptlang.org/play/#src=type%20Foo%20%3D%20'lol'%0A%0Aconst%20barr%3A%20Foo%20%3D%20%60lol%60

Expected behavior:

type Foo = 'lol'

const barr: Foo = `lol`
// No error

Actual behavior:

type Foo = 'lol'

const barr: Foo = `lol`
// Type 'string' is not assignable to type '"lol"'.
@ikatyang
Copy link
Contributor

ikatyang commented Aug 4, 2017

Duplicate of #16592.

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Aug 4, 2017
@DanielRosenwasser
Copy link
Member

Thanks for finding that @ikatyang!

@ghost ghost closed this as completed in #17704 Aug 10, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants