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
TypeEq<[number, ...number[]], number[]> is true, but should be false
TypeEq<[number, ...number[]], number[]>
true
false
export type TypeEq<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false; declare const foo: [number, ...number[]]; declare const bar: number[]; const test: TypeEq<typeof foo, typeof bar> = false; const foobar: typeof foo = bar; const barfoo: typeof bar = foo;
playground
The text was updated successfully, but these errors were encountered:
Consider this playground
type And<T extends any[]> = T extends true[] ? true : false; type IsExact<A, B> = [A, B] extends [B, A] ? true : false; export type TypeEq<A, B> = And<[ IsExact<A, B>, IsExact<(<T>() => T extends A ? 1 : 2), (<T>() => T extends B ? 1 : 2)> ]>; type MustBeTrue<T extends true> = T; type MustBeFalse<T extends false> = T; type Test = [ MustBeTrue<TypeEq<1, 1>>, MustBeTrue<TypeEq<[...1[]], 1[]>>, MustBeTrue<TypeEq<[...0[]], 0[]>>, MustBeFalse<TypeEq<[0?, ...0[]], false[]>>, MustBeFalse<TypeEq<[0?, ...(0 | undefined)[]], (0 | undefined)[]>>, MustBeFalse<TypeEq<[1, ...0[]], 0[]>> ];
Sorry, something went wrong.
This is a very strange behavior. It may be a bug of TypeScript
microsoft/TypeScript#31967
No branches or pull requests
TypeEq<[number, ...number[]], number[]>
istrue
, but should befalse
playground
The text was updated successfully, but these errors were encountered: