Open
Description
Some context
I made a function that takes an interface with 5 properties as an argument.
interface MyInterface {
readonly myProperty : string
readonly anotherProperty: number
optionalProperty1?: number[]
optionalProperty2?: number
// I can have some comments to describe this property in great detail
lastProperty: string
}
function interfaceConsumer(myVariable: MyInterface): string {
/* some code here */
return ""
}
TS knows everything about that interface, it shows hints about expected properties and would warn me when in function arguments I create an object not compatible with the interface.
So can I have a way to autocomplete that interface in function parameters?
I could copy-paste interface declaration, sure, but it's not the same and I would need to add commas, remove additional metadata or comments I might have there.
What would it look like?
interfaceConsumer({
myProperty : string
,anotherProperty : number
,optionalProperty1: number[] // ?
,optionalProperty2: number // ?
,lastProperty : string
})
- Leading commas and alignment are my personal preferences of course.
- Having types as initial "values" is quite crucial though: it's important to have there something invalid so that user does not leave a value unmodified by accident and having type information inserted could be handy IMO.
- Dropping information about optional arguments doesn't look like a good idea, so I'd insert it back with trailing comment.
The question
Can I have such interface autocompletion experience now?
Tell me if there are plugins/hotkeys/workflows I'm not aware of that would let me have this experience.