tsutils icon indicating copy to clipboard operation
tsutils copied to clipboard

Incorrect result from TSUtils.isTypeAssignableToString/Number

Open sstchur opened this issue 3 years ago • 0 comments

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

sstchur avatar Jul 20 '22 00:07 sstchur