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

ExpectType should allow subtypes #15

Open
danvk opened this issue Jan 22, 2017 · 2 comments
Open

ExpectType should allow subtypes #15

danvk opened this issue Jan 22, 2017 · 2 comments

Comments

@danvk
Copy link
Owner

danvk commented Jan 22, 2017

This test:

'hello'  // $ExpectType string

currently triggers this error:

Expected type
  string
but got:
  "hello"

The type "hello" extends string, so this should be allowed. If you really want to check that the type is "hello", then you should write // $ExpectType "hello".

@danvk
Copy link
Owner Author

danvk commented Jan 22, 2017

This is blocked on the TypeScript API exposing assignability checks.

@amir-arad
Copy link
Collaborator

amir-arad commented Jul 30, 2017

pseudo solvable by injecting a line with half of an assignment above the tested line.
so

'hello'  // $ExpectType string

is transformed to

const c1: string =  
'hello' 

and the we're left with line numbers and error translation.

Maybe use a different marker, say, // $ExpectAsType ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants