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

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

can I have a typescript class constructor that has input parameter guide?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
...