Answers
- The
flag
variable would be inferred to be aboolean
type. - The return type in the function is
void
. - An array of dates can be represented as
Date[]
orArray<Date>
. - A type error will not be raised on the
point
variable. It doesn’t need to include thez
property because it is optional. - A type for numbers 1-3 can be created as follows:
type OneToThree = 1 | 2 | 3;
- The
noEmitOnError
compiler option (set totrue
) can be used to prevent the transpilation process when a type error is found. - A union type can be used for the
lastSale
property to allow it to acceptnull
values:type Product = {
name: string;
lastSale: Date | null;
}
const table: Product = {name: "Table", lastSale: null}