Declare local variable as optional
Every time I type an undefinable variable, I think I typed something wrong: ```ts let a: string | undefined; ``` Why do I think I did something wrong? It's because I never add `undefined` type to a union type as above except in variable declarations. Don't you think it is time, introduce the optional operator to local variable declarations as well? ```ts let a?: string; ``` The above syntax feel very natural and idiomatic typescript for me.
Posted by tinganho on Jan 6, 2017, 11:45 AM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Declare local variable as optional
Every time I type an undefinable variable, I think I typed something wrong: ```ts let a: string | undefined; ``` Why do I think I did something wrong? It's because I never add `undefined` type to a union type as above except in variable declarations. Don't you think it is time, introduce the optional operator to local variable declarations as well? ```ts let a?: string; ``` The above syntax feel very natural and idiomatic typescript for me.
Comments (0)
No comments yet. Start the discussion.