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
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.
The text was updated successfully, but these errors were encountered:
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 (versustype
).This issue might be related to #5759 where the
interface
keyword acts differently to thetype
keyword.The text was updated successfully, but these errors were encountered: