User-defined Data Types

Apart from built-in data types, user can also define its own data type. User-defined types include Enumerations (enums), classes, interfaces, arrays, and tuple.

NOTE:

In built-in data types,

any:

is a special data-type, also the super data-type of all data types. If a variable is declared with any data type then we can assign any type value to that variable.

Examples:

let a: any = null; let b: any =123; let c: any = 123.456; let d: any = ‘Geeks’; let e: any = undefined; let f: any = true;


Data types in TypeScript

When you create a variable, you’re planning to give it a value. But what kind of value it can hold depends on the variable’s data type. In TypeScript, the type system defines the various data types supported by the language. The data type classification is as given below:

Similar Reads

Built-in Datatypes:

TypeScript has some pre-defined data-types-...

User-defined Data Types:

Apart from built-in data types, user can also define its own data type. User-defined types include Enumerations (enums), classes, interfaces, arrays, and tuple....