We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have an interface like this:
import { NumbersToN } from 'ts-number-range'; type Byte = NumbersToN<256>; interface RGBColor { r: Byte; g: Byte; b: Byte; }
Then I test:
expectAssignable<RGBColor>({ r: 0, g: 0, b: 0 }); // ✅ it passes expectAssignable<RGBColor>({ r: 0, g: 0, b: 256 }); // ✅ it failed expectNotAssignable<RGBColor>({ r: 0, g: 0, b: 0 }); // ❌ it passes expectNotAssignable<RGBColor>({ r: 0, g: 0, b: 256 }); // ✅ it passes
It seems expectNotAssignable<RGBColor>({ r: 0, g: 0, b: 0 }) not work correctly.
expectNotAssignable<RGBColor>({ r: 0, g: 0, b: 0 })
The text was updated successfully, but these errors were encountered:
Did you try:
expectAssignable<RGBColor>({r: 0, g: 0, b: 0} as const); expectAssignable<RGBColor>({r: 0, g: 0, b: 256} as const); expectNotAssignable<RGBColor>({r: 0, g: 0, b: 0} as const); expectNotAssignable<RGBColor>({r: 0, g: 0, b: 256} as const);
Because:
But:
Sorry, something went wrong.
Did you try: expectAssignable<RGBColor>({r: 0, g: 0, b: 0} as const); expectAssignable<RGBColor>({r: 0, g: 0, b: 256} as const); expectNotAssignable<RGBColor>({r: 0, g: 0, b: 0} as const); expectNotAssignable<RGBColor>({r: 0, g: 0, b: 256} as const); Because: But:
It works after I adding as const.
as const
No branches or pull requests
I have an interface like this:
Then I test:
It seems
expectNotAssignable<RGBColor>({ r: 0, g: 0, b: 0 })
not work correctly.The text was updated successfully, but these errors were encountered: