Reputation: 7165
Consider you have defined a class with a property like below but not yet set that property. Is there anyway to detect what type that property should be?
class User {
username: string;
}
let user = new User();
console.log(typeof user.username) // string ???
Upvotes: 0
Views: 34
Reputation: 220994
No. Types are erased. You can see this yourself by looking at the emitted JavaScript file; it is identical whether you wrote username: string
or username: number
.
Upvotes: 3