TypeScript Features
Static Typing:
It allows specifying data types for parameters and properties
let name: string
let age: number
Typescript Interfaces:
interface ICat{
name:string //Required Property in derived objects
age?:number //Optional Property
}
Objects implementing this interface should use properties of the same type
let fluffy: ICat
fluffy = { name: 'Fluffy'}
Typescript Class Properties:
class Student
{
private name: string
speak()
constructor(name)
{
}
}
Public-Private properties
In typescript, properties can be public/private. See above example. Below example also correct concerning class properties
class Student
{
constructor(private name)
{
}
}
No comments:
Post a Comment