-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
::=
type declaration shorthand
#176
Comments
|
Consolidating with #126 so we can see the consistency: // Type
User ::
name: string
// Object
user :=
name: 'John'
// Function
createUser := ({
id: userId: string
name:: string
...rest: SomeOtherProps
}) =>
// ... I like this. Edit: Not sure what the syntax for typing the object properties would be though. Probably not this, I guess: user :=
name: string: 'John' |
TypeScript already supports: const user = {
name: "John", // string is inferred
id: 7 as ID // cast number to ID
} |
There's the difference between declaration and assertion. const x: 'foo' | 'bar' = 'lalala' // Error
const y = 'lalala' as 'foo' | 'bar' // No error But we don't need to worry about this now. |
I'd prefer
In #126 we've discussed using user :=
name:: string: 'John' |
Besides |
|
Makes sense because type declarations have an equal sign and interface declarations don’t. |
Just pointing out that using |
…tion shorthand
I just noticed, this is still marked as "TODO" in the README... |
Suggested by @sultan99 with some modifications.
The text was updated successfully, but these errors were encountered: