Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Sorry I am new in Javascript and Typescript.

in Swift using Xcode IDE, if I make a class, then If I make an instance, it will have its parameter name as a guide in the constructor, like the image below, so I will not put the wrong value in the constructor

enter image description here

but if I use Typescript and do the same thing, I will not have that parameter guide like this

enter image description here

it is easy if the class only has 2 properties like that, but if it has more than 10 properties then it will be confusing, I often put the wrong argument

is there a way to make something like that? VS Code extension or whatever it is. please help :)

class User {
    name: string
    age: number
    
    constructor(name: string, age: number) {
        this.name = name;
        this.age = age;
    }
}

const someone = new User("John Doe", 12);
question from:https://stackoverflow.com/questions/66058954/can-i-have-a-typescript-class-constructor-that-has-input-parameter-guide

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...