Informing Typescript that a Value Will Be Initialized

Our LitElement has the following code:

And Typescript linting produces this error:

Property ‘gist’ has no initializer and is not definitely assigned in the constructor.

We want to clear this error.

Add an exclamation point (! — formally the Typescript non null assertion operator) after the property name like this:

This tells Typescript that the value will be initialized.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ole Ersoy

Ole Ersoy

Founder of Firefly Semantics Corporation