Variable 'test' is used before being assigned - Typescript
To clarify a little, this hinges on the difference between "assigned" and "defined." For example:
let myDate: Date; // I've defined my variable as of `Date` type, but it still has no value.
if (!someVariable) {
myDate = new Date();
}
console.log(`My date is ${myDate}`) // TS will throw an error, because, if the `if` statement doesn't run, `myDate` is defined, but not assigned (i.e., still has no actual value).
Defining simply means giving it an initial value:
let myDate: Date | undefined = undefined; // myDate is now equal to `undefined`, so whatever happens later, TS won't worry that it won't exist.
let test!: A;
add a '!' after variable name
see: typescript/playground