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

Incorrect result from TSUtils.isTypeAssignableToString/Number #144

Open
sstchur opened this issue Jul 20, 2022 · 0 comments
Open

Incorrect result from TSUtils.isTypeAssignableToString/Number #144

sstchur opened this issue Jul 20, 2022 · 0 comments

Comments

@sstchur
Copy link

sstchur commented Jul 20, 2022

If you have code like this:

let p: { toFixed: () => string };

And if you use TSUtils.isTypeAssignableToNumber(checker, type) where type comes from the AST and refers to a type like: { toFixed: () => string };, it should return true, but it returns false. This also happens for the type { } which should also return true for any number. Similar issues happens for isTypeAssignableToString.

This TS playground link demonstrates that all of these are assignable to either number or string, but I get the wrong value from isTypeAssignableToNumber/String in all cases:

https://www.typescriptlang.org/play?#code/DYUwLgBADgXBDeEwHsBiBLAHiAJnAFAJQQC8AfBAM5gBO6AdgOYDcEAvqRAEwCszAUP1CQAjnEQcSEAMwAWPoOERM4pMgCqUKCBoBhAIaUQBYuSq0GLdpwDkNgUPAQAnqskQbAdwAW+sCAA3HXsgA

I'm using TS 4.7.2 by the way and TSUtils 3.17.1

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