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
inference identical
3.5-3.9, 4.0-4.6, 4.7.0-dev.20220304 (did not test earlier versions)
Playground link with relevant code
type Identity<A> = A extends object ? {[K in keyof A]: Identity<A[K]>} : A; type HasValue1<A> = { value:Identity<A>; } type HasValue2<A> = { value:Identity<A>; } function test<B>(a:HasValue1<B>) {} function foo1<A>(a:HasValue1<A[]>) {test(a)} // OK function foo2<A>(a:HasValue2<A[]>) {test(a)} // type-error
The body of foo2 does not type-check because the wrong type for type-variable B is inferred.
foo2
The body of foo2 should type-check exactly as foo1 since HasValue1 and HasValue2 are structurally the same type.
foo1
HasValue1
HasValue2
The text was updated successfully, but these errors were encountered:
@ahejlsberg I heard you like variance issues
Sorry, something went wrong.
ahejlsberg
No branches or pull requests
Bug Report
π Search Terms
inference identical
π Version & Regression Information
3.5-3.9, 4.0-4.6, 4.7.0-dev.20220304 (did not test earlier versions)
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The body of
foo2
does not type-check because the wrong type for type-variable B is inferred.π Expected behavior
The body of
foo2
should type-check exactly asfoo1
sinceHasValue1
andHasValue2
are structurally the same type.The text was updated successfully, but these errors were encountered: