Using @query with LitElement and Typescript

Viewed 473

I'm trying to do this:

@query('#gist')
gist: HTMLIFrameElement;

And the typescript linting says:

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

How do we clear this?

1 Answers

You can use a ! after the property name. This tells Typescript that the value will be set.

@query('#gist')
gist!: HTMLIFrameElement|null;
Related