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

Type { toUpperCase: () => string; } | undefined should be assignable the value '' #84

Open
sstchur opened this issue Aug 4, 2022 · 0 comments

Comments

@sstchur
Copy link

sstchur commented Aug 4, 2022

The Type { toUpperCase: () => string; } | undefined should be assignable the value '', but when I get a type like the aforementioned type using checker.getTypeAtLocation(node) and then use it like isAssignableToValue(type, '') it returns false.

You can clearly see that it should work by just trying it out in the TS playground:

let x: { toUpperCase: () => string; } | undefined = '';

TS has no problem with the above code b/c '' "looks like" a string (since all strings have .toUpperCase() which returns a string.

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

1 participant