Answer the question
In order to leave comments, you need to log in
What is the correct way to type number|null?
I'm trying to write:
export interface ApplicationInit {
initialPayment: number|null;
}
const initialState: ApplicationInit = {
initialPayment: null,
};
Answer the question
In order to leave comments, you need to log in
An interface in TypeScript can have multiple declarations in code, and TypeScript will combine them all into one generic type. Judging by the error with your ApplicationInit, this is exactly what happened, in addition to the initialPayment field, other fields are declared in another declaration, which is why it requires them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question