Answers for "typescript exclamation mark"

0

typescript exclamation mark

//Normally when you declare a member (which doesn't include undefined in it's type) 
//it has to be initialized directly or in the constructor. 
//Otherwise Typescript will raise an error.
//If you add ! after the name, TypeScript will ignore this and not show an error 
//if you don't immediately initialize it:

//Example

foo: string; // error: Property 'foo' has no initializer and is not definitely assigned in the constructor.
bar!: string; // no error
Posted by: Guest on February-07-2022

Code answers related to "TypeScript"

Browse Popular Code Answers by Language