Skip to content

TypeScript type & interface Props configuration #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
talohana opened this issue Dec 11, 2020 · 4 comments
Closed

TypeScript type & interface Props configuration #157

talohana opened this issue Dec 11, 2020 · 4 comments

Comments

@talohana
Copy link

TypeScript allows to model types with 2 options - a type and an interface.

A comparison between the two can be found in this blogpost
Is there an option to change the TypeScript snippets to use types instead of interfaces when declaring the Props type?

For example instead of generating with tsrafc

interface Props {}

export const Example = (props: Props) => <> ... </>;

to generate

type Props = {};

export const Example = (props: Props) => <> ... </>;
@ice-chillios
Copy link

@talohana There is #62 an issue to track those. Unfortunately I didn't have time to look how to implement those options and then apply changes to json files. I thought of some placeholders and then replacing with proper value i.e.:

Option with select options: Interface / Props

and then based on this value replace all occurrences of this placeholder in snippets, but it would also force users to restart whole VSCode as snippets are loaded on start AFAIK.

@andrewphamvk
Copy link

andrewphamvk commented Apr 11, 2021

Editing C:\Users{user}.vscode\extensions\dsznajder.es7-react-js-snippets-3.1.1\snippets\ts-snippets.json and replacing interface with type and adding the additional = is a good workaround.

@talohana
Copy link
Author

Editing C:\Users{user}.vscode\extensions\dsznajder.es7-react-js-snippets-3.1.1\snippets\ts-snippets.json and replacing interface with type and adding the additional = is a good workaround.

Is there a way to save this change with vscode settings sync?

@ice-chillios
Copy link

ice-chillios commented Sep 16, 2021

Tracked in #175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants