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 generic types
https://www.typescriptlang.org/play/?ts=5.7.2#code/MYGwhgzhAEBqYCcCWYBGICmAeAqgGmgGVoMAPAFwwDsATGCc5KgcwD5oBvAKGmmAHsqDBAFdg5fggAUABxHokwaBABcRAJSdoAXx7QRAQjU4A3F11cAZiKrikg6AFsA1gHFqGZMFwFiZSrT0jEgsrFKqGpx6CBjkIghU0FQYAO5wiCjo2PhEYRDq5lxc5ACeMhjQAKKkYOIAggjMAHJgjhgQWO7JXgAqZRgEAMKCwmAh5OwAvNBdnop95dAAZFG8ANoA0tAh0M4YJfyWMx69-QC6alv+1HS7+4fQw0KMY1Tk0AD8x93z-Ztn0DUyQAbp5CsV+tA6iAQPwUvBkGhMB0elN0oislgegQwFQSuwAD5aTbbRJ7A5HHoXdGZTBY-44vGE6A9f46IqlRY9drkBrMGDTbi8CD8Np8oEiRyoMEWTkVbkMPkQADqSHIAAsEQKoTC4Qjae0sTylawitZbOR7IlyGA9hBZl4sLASBQbjBobD4RkkYaFbzGhBWGEwGpqrV-c1WobYAQ-Sb1GpgfwkDQohZMO9gdBpja7Q7FFIOCKxY01C588ApAAiUhV9TadRmIA
class Variable<U, S extends string> { constructor(public s: S) { } u!: U; } function mkGeneric<U, S extends string>(s: S) { return new Variable<U, S>(s) } type ExactArgNames<GenericType, Constraint> = GenericType & { [K in keyof GenericType]: K extends keyof Constraint ? GenericType[K] : never } type AllowVariables<T> = Variable<T, any> | { [K in keyof T]: Variable<T[K], any> | T[K] } type TestArgs = { someArg: number } type TestArgsWithVars = AllowVariables<TestArgs> function takesGeneric<V extends AllowVariables<TestArgs>>(a: ExactArgNames<V, TestArgs>): void { } let v = takesGeneric({someArg: mkGeneric("x")});
VVersion 5.7.2 of the compiler infers the variable type as Variable<uknown, "x"> and subsequently generates an error
VVersion 5.6.3 of the compiler infers the variable type correctly as Variable<number, "x">
Variable<number, "x">
This is breaking most code that uses typed-graphql-builder typed-graphql-builder/typed-graphql-builder#85
The text was updated successfully, but these errors were encountered:
No branches or pull requests
π Search Terms
inference generic types
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.7.2#code/MYGwhgzhAEBqYCcCWYBGICmAeAqgGmgGVoMAPAFwwDsATGCc5KgcwD5oBvAKGmmAHsqDBAFdg5fggAUABxHokwaBABcRAJSdoAXx7QRAQjU4A3F11cAZiKrikg6AFsA1gHFqGZMFwFiZSrT0jEgsrFKqGpx6CBjkIghU0FQYAO5wiCjo2PhEYRDq5lxc5ACeMhjQAKKkYOIAggjMAHJgjhgQWO7JXgAqZRgEAMKCwmAh5OwAvNBdnop95dAAZFG8ANoA0tAh0M4YJfyWMx69-QC6alv+1HS7+4fQw0KMY1Tk0AD8x93z-Ztn0DUyQAbp5CsV+tA6iAQPwUvBkGhMB0elN0oislgegQwFQSuwAD5aTbbRJ7A5HHoXdGZTBY-44vGE6A9f46IqlRY9drkBrMGDTbi8CD8Np8oEiRyoMEWTkVbkMPkQADqSHIAAsEQKoTC4Qjae0sTylawitZbOR7IlyGA9hBZl4sLASBQbjBobD4RkkYaFbzGhBWGEwGpqrV-c1WobYAQ-Sb1GpgfwkDQohZMO9gdBpja7Q7FFIOCKxY01C588ApAAiUhV9TadRmIA
π» Code
π Actual behavior
VVersion 5.7.2 of the compiler infers the variable type as Variable<uknown, "x"> and subsequently generates an error
π Expected behavior
VVersion 5.6.3 of the compiler infers the variable type correctly as
Variable<number, "x">
Additional information about the issue
This is breaking most code that uses typed-graphql-builder typed-graphql-builder/typed-graphql-builder#85
The text was updated successfully, but these errors were encountered: