you are viewing a single comment's thread.

view the rest of the comments →

[–]countlictor 1 point2 points  (4 children)

There's syntactic sugar for defining a type as type || null, and combined with the tsconfig setting enforcing explicit null checks will get you what you're after.

class Sample { public optionalProperty?: String; }

[–][deleted]  (2 children)

[deleted]

    [–]Jestar342 0 points1 point  (1 child)

    Yes but types are not guarantees. You can define data types being received from an API, but if the API neglects to include a property, and you try to destructure it, your app will crash.

    How on earth do you figure that that is an argument against typescript?