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
TypeScript Version: 4.1.x and 4.2.0-dev.20201123
Works on 4.0.x
Search Terms: TS7053
Code
export type ComparablePrimitives = undefined | null | boolean | string | number;
export type ComparableArray = Array< Comparable >;
export type ComparableObject = { [ key: string ]: Comparable; };
export type Comparable =
| ComparablePrimitives
| ComparableArray
| ComparableObject;
export function isEqual< T extends Comparable >( a: T, b: T ): boolean;
export function isEqual< T extends Comparable, U extends Comparable >( a: T, b: U ): false;
export function isEqual< T extends Comparable, U extends Comparable >( a: T, b: U ): boolean
{
if ( Array.isArray( a ) && Array.isArray( b ) )
return !a.some( ( value, index ) => !isEqual( value, b[ index ] ) );
return false;
}
(the function body in this example is not my real code, but shows the compilation error)
Expected behavior: should compile
Actual behavior: fails with:
TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type '(undefined & (U extends readonly any[] ? unknown extends U ? never : readonly any[] : any[])) | (null & (U extends readonly any[] ? unknown extends U ? never : readonly any[] : any[])) | (string & (U extends readonly any[] ? unknown extends U ? never : readonly any[] : any[])) | ... 4 more ... | (ComparableObject & ...'.
No index signature with a parameter of type 'number' was found on type '(undefined & (U extends readonly any[] ? unknown extends U ? never : readonly any[] : any[])) | (null & (U extends readonly any[] ? unknown extends U ? never : readonly any[] : any[])) | (string & (U extends readonly any[] ? unknown extends U ? never : readonly any[] : any[])) | ... 4 more ... | (ComparableObject & ...'.
return !a.some( ( value, index ) => !isEqual( value, b[ index ] ) );
~~~~~~~~~~
Related Issues:
The text was updated successfully, but these errors were encountered:
@DanielRosenwasser no, I just tried it, and I get quite a few new errors in other parts of the codebase, but this one error is not affected, it's still there, without noUncheckedIndexedAccess specified, or with it explicitly true or false.
TypeScript Version: 4.1.x and 4.2.0-dev.20201123
Works on 4.0.x
Search Terms: TS7053
Code
(the function body in this example is not my real code, but shows the compilation error)
Expected behavior: should compile
Actual behavior: fails with:
Related Issues:
The text was updated successfully, but these errors were encountered: