Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #typescript #exclamation #mark
ADD COMMENT
Topic
Name
9+5 =