Open
Description
π Search Terms
array, constructor, bracket
π Version & Regression Information
- This is a crash
β― Playground Link
π» Code
// @noLib: true
// @target: esnext
declare global {
const Array: {
<T = unknown>(...args:any[]): Array<T>
new <T = unknown,>(...args:any[]): Array<T>
}
type Array<T> = {
[i: number]: T
length: number
}
}
// all of the below give "Property 'length' is missing in type '{}'...":
; ([1, 2, 3]) satisfies Array<number>;
; ([1, 2, 3]) satisfies { length: number };
declare const ar1: never[]
; ar1 satisfies { length: number };
declare const ar2: number[]
; ar2 satisfies { length: number }
// this should throw an error but it doesn't
// @ts-expect-error
; ([] as number[]) satisfies string[]
export { }
π Actual behavior
Types created with the T[]
and objects created with the [x as T]
syntax are not typed as Array<T>
but instead as {}
.
π Expected behavior
I expect either:
T[]
syntax andArray<T>
to be completely synonymous- A compiler error that the
Array
type is not an instantiable type
Additional information about the issue
Related to #57009.