Closed
Description
π Search Terms
type assertion readonly array
π Version & Regression Information
Latest as of today.
β― Playground Link
π» Code
interface NormalArray {
arr: string[];
}
/* --- object type --- */
declare const a: { arr: readonly string[] }; // also works with an interface here.
(a as NormalArray); // works π
/* --- namespace --- */
declare namespace N {
export const arr: readonly string[];
}
(N as NormalArray); // works π
declare const n: typeof N;
(n as NormalArray); // works π
/* --- */
declare class Foo {
static arr: readonly string[];
arr: readonly string[];
}
/* --- instance --- */
declare const i: Foo;
(i as NormalArray); // works π
/* --- class --- */
(Foo as NormalArray); // doesn't work β
declare const c: typeof Foo;
(c as NormalArray); // doesn't work β
π Actual behavior
The type assertion works with everything except on static properties.
π Expected behavior
Works with everything?
Additional information about the issue
Is there a special reason for this not to work with static properties? Or should this work in all cases? Or should this not work in any case?
Metadata
Metadata
Assignees
Labels
No labels