Syntax

TypeScript Non-null Assertion Syntax

In TypeScript, non-null assertion: tells the compiler a value isn't null or undefined — el!.focus();

Quick Answer

Syntax
el!.focus();
TypeScriptSyntax

Non-null Assertion

Code example
el!.focus();

Tells the compiler a value isn't null or undefined.

Learn More

How to non-null assertion in TypeScript

  1. Open your TypeScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

TypeScript Non-null Assertion Syntax

Use el!.focus();.

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for non-null assertion?

Use this pattern: el!.focus();

Can I copy this TypeScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this TypeScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify