ts class code example
Example 1: ts class
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}}
let greeter = new Greeter("world");Try
Example 2: classes in typescript
class Info {
private name: string ;
constructor(n:string){
this.name = n ;
};
describe(){
console.log(`Your name is ${this.name}`);
}
}
const a = new Info('joyous');
a.describe();
Example 3: export interface typescript
interface Props {}
export interface IRefered {
name: string
}
Example 4: classes in ts
class Greeter { greeting: string;
constructor(message: string) { this.greeting = message; }
greet() { return "Hello, " + this.greeting; }}
let greeter = new Greeter("world");Try