π Search Terms
satisfies, enum
β
Viability Checklist
β Suggestion
I suggest that TypeScript should allow this:
enum Foo {
Foo = "Foo" satisfies "Foo"
}
Currently this is treated as a computed enum member and requires number type, despite nothing being actually computed here.
π Motivating Example
With isolatedModules/isolatedDeclarations enabled references in enum members are restricted. For example, this does not compile with isolatedDeclarations:
const FOO = "Foo"
enum Foo { Foo = FOO }
// Error: Enum member initializers must be computable without references to external symbols with --isolatedDeclarations.
satisfies here will ensure that Foo is properly typed while not referring to external symbols:
const FOO = "Foo"
enum Foo { Foo = "Foo" satisfies typeof FOO }
π» Use Cases
See motivating example above.
π Search Terms
satisfies, enum
β Viability Checklist
β Suggestion
I suggest that TypeScript should allow this:
Currently this is treated as a computed enum member and requires
numbertype, despite nothing being actually computed here.π Motivating Example
With
isolatedModules/isolatedDeclarationsenabled references in enum members are restricted. For example, this does not compile withisolatedDeclarations:satisfieshere will ensure thatFoois properly typed while not referring to external symbols:π» Use Cases
See motivating example above.