This seems fine, but I'll give you a neat trick
https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBAYwDYEMDOa4FU3CnAbwCg5TEIA7NGKAVwRmgAoSy2xaAjJASwTgBmPKNQD6FFAFtgALjjUoPCgHMANKzakO3PnFRiJ0uQqVqNm7b35goEIUmCiek5cZqn1mspd3BJKHiQ3RRVzAEpCOABfIhigA
Normally you don't want any "any" types, so try to remove the "user_details: any", and replace it with some proper object types
Basically, prefix any argument to a constructor with an access specifier, and TypeScript will automatically generate the assignments
export class User { constructor( public first_name: string, public last_name: string, public profile_img: string, public email: string ) { } } omg nice but how can i initialize these?
new User('Thomas', 'Anonymous', 'thomas.png', 'thomas@example.com');
ooooo, see i cant do that cuz
Do you come from C# or Java?
yea i pretty much implemented all of the Data structures in JAVA only.....
Well in JS / TS you often don't need this much class stuff
Обсуждают сегодня