Open rotu opened 10 months ago
Just to be clear, this isn't going to work
Just to be clear, this isn't going to work
lol, I know. I reduced the repro example from something like type Array<T> = T[] & { push: (t: T) => number }
(which is also wrong)
I expect this code to give an error about a circular type reference as if I had written type Array<T> = Array<T>
It seems there's an internal failure that happens before this crash. It's not my particular definition of the Array
type that's a problem but using a type alias to define Array
at all:
// @noLib: true
// okay with this definition of Array:
// interface Array<T> {
// [i:number]:T
// }
// okay with this definition of Array, too:
// class Array<T> {
// [i:number]:T
// }
// With this definition, things fail and number[] is not the same type as Array<T> anymore:
type Array<T> = {
[i:number]:T
}
[1,2,3] satisfies {[i:number]:any}
declare const x:number[]
// ^?
x satisfies Array<number>
:wave: Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of this repro running against the nightly TypeScript.
Comment by @rotu
:x: Failed: -
Type '{}' does not satisfy the expected type '{ [i: number]: any; }'.
Index signature for type 'number' is missing in type '{}'.
Type '{}' does not satisfy the expected type 'Array'.
Index signature for type 'number' is missing in type '{}'.
Version | Reproduction Outputs |
---|---|
4.9.3, 5.0.2, 5.1.3, 5.2.2, 5.3.2 |
:x: Failed: -
|
It seems there's an internal failure that happens before this crash. It's not my particular definition of the
Array
type that's a problem but using a type alias to defineArray
at all
moved this to standalone issue #57564
π Search Terms
Array type define crash
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/dev/bug-workbench/?noLib=true#code/PTAEAEDsHsBkEsBGAuUAXATgVwKYCg0BPABx1AEEMMBDQgHgBUA+UAXlAYG0BdAbjyA
π» Code
π Actual behavior
Typescript crashes:
π Expected behavior
I expect an error message.
Additional information about the issue
No response