In this article we will learn about some of the frequently asked TypeScript programming questions in technical like “typescript assign two types” Code Answer’s. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error or stack handling on typescript was simple and easy. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in Typescript. Below are some solution about “typescript assign two types” Code Answer’s.
typescript assign two types
xxxxxxxxxx
1
// refered to as union types in typescript
2
interface Foo {
3
bar:string|boolean;
4
}
merge two types typescript
xxxxxxxxxx
1
interface IStudent {
2
id: string;
3
age: number;
4
}
5
6
interface IWorker {
7
companyId: string;
8
}
9
10
type IStudentAlias = IStudent;
11
12
type ICustomType = IStudent | IWorker;
13
14
let s: IStudentAlias = {
15
id: 'ID3241',
16
age: 2
17
};