Skip to content

Suggestion: non-nullable type #185

Description

Introduce two new syntax for type declaration based on JSDoc

varmyString: !string='hello world';//non-nullablevarmyString1: ?string='hello world';// nullable varmyString2: string='hello world';// nullable varmyString3='hello world';// nullable

by default type are nullable.

Two new compiler flag :

  • inferNonNullableType make the compiler infer non-nullable type :
varmyString3='hello world'// typeof myString is '!string', non-nullable
  • nonNullableTypeByDefault (I guess there might be a better name) :
varmyString: !string='hello world';// non-nullablevarmyString1: string='hello world';// non-nullable varmyString2: ?string='hello world';// nullable varmyString3='hello world'// non-nullable

Metadata

Metadata

Labels

CommittedThe team has roadmapped this issueFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions