Is there a way to prevent this behavior? It's crucial when compiling type declarations solely for libraries.
I specifically require it for compiling declarations only:
tsc --declaration true --emitDeclarationOnly true
Here is a minimal example of the code:
function test<T>(t: T): Omit<T, 'href'> {
return t;
}
export const TEST_CONST = test({} as HTMLAnchorElement);
Expected output:
export declare const TEST_CONST: Omit<HTMLAnchorElement, 'href'>
Received output:
export declare const TEST_CONST: Pick<HTMLAnchorElement, "toString" | "search" | ... (truncated for brevity) ... | "protocol" | "username">;
An explicit type declaration will function, but can be cumbersome with lengthy chains of function calls:
function test<T>(t: T): Omit<T, 'href'> {
return t;
}
export const TEST_CONST: Omit<T, 'href'> = test({} as HTMLAnchorElement);