-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
Description
interface NumberArray extends Array<number> { }
function doSomething(x: NumberArray | null) {
if (Array.isArray(x)) {
printString(x); // Why does this work?
printNumber(x); // Why does this work?
printBoolean(x); // Why does this work?
printArray(x);
}
}
function printString(x: string) {
}
function printNumber(x: number) {
}
function printBoolean(x: boolean) {
}
function printArray(x: Array<any>) {
}
If I use type NumberArray = Array<number>; then everything works as expected.
I tried this in the TypeScript playground and the errors show up as expected. I tried reading Flow's documentation on interfaces but I couldn't find any reason why the declaration using interface shouldn't work (versus type).
This issue might be related to #5759 where the interface keyword acts differently to the type keyword.
Reactions are currently unavailable