Closed as not planned
Description
π Search Terms
typed array
Uint8Array
ArrayBufferLike
π Version & Regression Information
- This changed between versions 5.6 and 5.7
β― Playground Link
No response
π» Code
This is a very simple file that exports a Uint8Array
parser created by a factory method:
export type Parser<T> = (input: string) => T
function createUint8ArrayParser(): Parser<Uint8Array> {
return (_input: unknown): Uint8Array => {
throw new Error('Not implemented')
}
}
export const parser = createUint8ArrayParser()
π Actual behavior
The resulting .d.ts
file looks as follows:
export type Parser<T> = (input: string) => T;
export declare const parser: Parser<Uint8Array<ArrayBufferLike>>;
The type returned for parser
includes the generic version of Uint8Array
which basically mean that anything depending on this export must also be at least on version 5.7.
When importing this in a project using TypeScript 5.6 we get an error:
TS(2315): Type 'Uint8Array' is not generic.
π Expected behavior
The type returned for parser
should be Parser<Uint8Array>
and not Parser<Uint8Array<ArrayBufferLink>>
export type Parser<T> = (input: string) => T;
export declare const parser: Parser<Uint8Array>;
Additional information about the issue
No response