typescript-go
typescript-go copied to clipboard
Error on unused generic type argument when declaring multiple function signatures
Declaring multiple function signatures that receive a generic type parameter T allows for some of the signatures not to use T but still declare it in current typescript. In the native port however this generates an error.
export function max<T>(a: undefined, b: undefined): undefined;
export function max<T extends number>(
a: T | undefined,
b: T | undefined
): T | undefined;
export function max<T extends number>(
a: T | undefined,
b: T | undefined
): T | undefined {
return a ?? b;
}
Arguably this should have been an error before, but it's currently allowed.