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
Literals should be allowed as types, and they will be subtypes, processed via the Satisfies constraint, of their parent types. For example,
type Foo = '"this" | '"that"; -- the ' denotes that it is a type, and not a value.
Then, fn foo(foo in 'Foo) could only ever accept "this" or "that". But fn foo(foo in 'string) could accept a 'Foo, or any other string.
This is more ergonomic than having to define an enum with to_str() and from_str() like Rust, and is one of the more valuable features from the Typescript type system that I enjoy.
The text was updated successfully, but these errors were encountered:
Literals should be allowed as types, and they will be subtypes, processed via the
Satisfies
constraint, of their parent types. For example,type Foo = '"this" | '"that";
-- the'
denotes that it is a type, and not a value.Then,
fn foo(foo in 'Foo)
could only ever accept "this" or "that". Butfn foo(foo in 'string)
could accept a'Foo
, or any other string.This is more ergonomic than having to define an enum with
to_str()
andfrom_str()
like Rust, and is one of the more valuable features from the Typescript type system that I enjoy.The text was updated successfully, but these errors were encountered: