Skip to content

Incorrect result from TSUtils.isTypeAssignableToString/Number #144

Description

@sstchur

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions