VSCode's intellisense has an option for pulling in the required interface members. Can it also do this for TypeScript Types?
For example if I have an exported type:
export type Button = {
id: string;
text: string;
color?: ColorOptions;
icon?: string;
tooltip?: Tooltip;
};
When I create a new object:
const button: Button = {
// No Code Actions.
}
I don't have any code actions to fill in the required properties.
I would honestly like it to also have an option to pull in optional props as well. I know I can peek + copy + paste, but then I have to reformat, as the syntax for defining and using a type is not the same.
Does this functionality exist?
Update: this is going to be part of Typescript in a future release, so you won't need to install this extension anymoire. https://github.com/microsoft/TypeScript/pull/44576
I've made a typescript language server plugin and vscode extension called TS Quickfixes that adds this functionality. It's very basic and doesn't support many cases yet, so please raise an issue if your use case isn't covered: https://github.com/tamj0rd2/ts-quickfixes
Extension: https://marketplace.visualstudio.com/items?itemName=tamj0rd2.ts-quickfixes-extension
Language server plugin: https://www.npmjs.com/package/ts-quickfixes-plugin
As of VS Code 1.36, that quick fix is not available.
The feature request is being tracked here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With