You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypedArray-related errors with TypeScript 5.7.2 #58
I don't know why it fails to pickup the 3-argument version of the typed constructors. Probably related to microsoft/TypeScript#59417? Any help from people more well versed in TypeScript appreciated.
@rbuckton perhaps you could give a hint on what might be wrong here? The typings depend on a union of *Constructor typed array types here, and for some reason it doesn't resolve to the 3-argument version of the constructor after updating from TS 5.6.
When you union constructor types, generic signatures must match exactly. Since each constructor type in the union produces a different return type, they are excluded from the resulting set. In the long term, I can look into adding non-generic overloads for these cases. As a workaround, you can define an alternative union for generic use:
@rbuckton thank you for the prompt response! I can't get it to work so far, getting some errors that are cryptic to me, but perhaps I should just silence the error because it is getting into territory too complicated for simple typing I intended for the library.
Do the union constituents match what they were previously? From the error you provided it sounds like Uint8ClampedArray might not have been included previously?
@rbuckton good catch, that was one of the problems. I managed to get the typecheck passing in #59, but it looks ugly as hell now — not sure whether I should merge this or wait for new TS versions if they're going to address cases like this...
Activity
mourner commentedon Jan 8, 2025
@rbuckton perhaps you could give a hint on what might be wrong here? The typings depend on a union of
*Constructortyped array types here, and for some reason it doesn't resolve to the 3-argument version of the constructor after updating from TS 5.6.rbuckton commentedon Jan 8, 2025
When you union constructor types, generic signatures must match exactly. Since each constructor type in the union produces a different return type, they are excluded from the resulting set. In the long term, I can look into adding non-generic overloads for these cases. As a workaround, you can define an alternative union for generic use:
mourner commentedon Jan 8, 2025
@rbuckton thank you for the prompt response! I can't get it to work so far, getting some errors that are cryptic to me, but perhaps I should just silence the error because it is getting into territory too complicated for simple typing I intended for the library.
My JSDoc looks like this:
And one of the errors is:
rbuckton commentedon Jan 9, 2025
This is tracked by microsoft/TypeScript#60745.
rbuckton commentedon Jan 9, 2025
Do the union constituents match what they were previously? From the error you provided it sounds like
Uint8ClampedArraymight not have been included previously?mourner commentedon Jan 10, 2025
@rbuckton good catch, that was one of the problems. I managed to get the typecheck passing in #59, but it looks ugly as hell now — not sure whether I should merge this or wait for new TS versions if they're going to address cases like this...
upgrade dev deps, use ts-expect-error for now (ref #58)
mourner commentedon Mar 10, 2025
Nice to see all these issues resolved after upgrading to a newer TS version!
upgrade dev deps, close mourner#58