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

stuck with this compilation error for a while. Suppose we have this property defined;

public result = Result

If we want to initialize above property only, we can write it like this;

public result! = Result

Second alternative is to open sconfig.json and set

"compilerOptions": {
    "strictPropertyInitialization": false,
    ...
}

This will be a project wide change and you don’t need to initialize all your variables.

https://stackoverflow.com/questions/49699067/property-has-no-initializer-and-is-not-definitely-assigned-in-the-construc

FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect