The use of Typescript is amazing for web/app development, however we must remember that Typescript is a javascript’s superset and it will be transpiled in pure js with all limitation of the case.
Let’s see a courios case I’ve faced today.
export class User { // class attributes public name: string = ""; public surname: string = ""; // class properties public get FullName(): string { return this.name + " " + this.surname; } public SayHello() { console.log("Hello " + this.FullName); } }
How you can see on the code block above, we have a class named User with two attributes, Name and Surname, and a readonly property, FullName.
function ConvertObject<T>(arg: any): T { const result: T = {} as T; return Object.assign(result, arg) as T; }Continue reading “Typescript object VS javascript object”