Issue
I have got an interface like this
export interface ReportFiles {
ReportName: string;
Log: number;
MyFile: File;
}
And in my component, I declared the object as
export class MyComponent Implements OnInit {
RF: ReportFiles = { ReportName: "", Log: 0, MyFile: null }
...
...
}
The error message shows
'null' is not assignable to File
How can I resolve this?
Solution
Specify MyFile
with nullable type.
interface ReportFiles {
ReportName: string;
Log: number;
MyFile?: File | null;
}
Sample Demo on Typescript Playground
Answered By - Yong Shun
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.