How to disable bang operator (!) in property initialization in js/ts

72 Views Asked by At

Since I have set strict: true style rule, I will get the Property has no initializer and is not definitely assigned in the constructor.ts(2564) error if I don't set initiation on a variable. I am able to bypass the error by adding bang operator ("!") after the variable name. For example, test!: string;.

However, I would like to avoid using the bang operators. Is it possible to force developers to use test: string | undefined; instead?

I tried @typescript-eslint/no-non-null-assertion": "error", but it didn't report errors for bang operators in property initialization. Any ideas?

0

There are 0 best solutions below