Open nektro opened 2 months ago
TypePrimitive:
undefined
object
boolean
number
bigint
string
symbol
Type
TypePrimitive
TypePrimitive [ ]
TypeAnnotation:
?(opt) : Type
LexicalDeclaration:
LetOrConst Identifier TypeAnnotation(opt) Initializer(opt)
FieldDefinition:
ClassElementName TypeAnnotation(opt) Initializer(opt)
production OptionalAssertion
would be quite similar to OptionalChain
but with ?.
swapped for !.
I think a first iteration of this proposal should limit itself to only the values from
typeof
, arrays, and classes in function parameter / variable / class field definitions. maybe the?:
and!.
syntax too. this would provide an a common base that's easy for engines and tools to adopt while still being enough to bring immediate benefit to developers.the readme goes into great depth about prior art but I dont think we should worry about tying ourselves strictly to being source-compatible with TypeScript due to the reasons y'all already have listed wrt standardization and not breaking the web. even though they and others have done a great job paving the road.
I also agree with engines ignoring the types at runtime while making the types available to tooling being invaluable. and that putting the types in-source is much better than in-comments.
type declarations etc massively increase the scope and potential ambiguity in the syntax. I think it would be very beneficial to developers and the prospects of getting this landed if we started much smaller and added other features in future proposals.
great work getting this to stage 1 and I'd love to help out materially where I can to help this along :)