You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a command to extract a class interface to file.
How would it work
The command would take the output from the existing Extract Interface command and rather than placing the extraction at the bottom of the current file, it would create a new file and place the extracted interface there.
Expected behavior
The name of the extraction file should follow general interface filename convention: IClassName.ts
The name of the extracted interface should follow the same convention: IClassName
The interface declaration should be prefixed with the export keyword: export interface IClassName {...}
Any dependent imports should be added to the top of the file before the export interface
An error notification should display if a file of the same name already exists: "Interface file already exists."
The text was updated successfully, but these errors were encountered:
I think I'd tweak a little bit the expected behavior so we ask the user which name they want to give their interface. We may provide a default input, but that will make it easier to change rather than having to rename the created file if you have a different convention (e.g. personally, I tend to avoid I in the interface name, but that's a personal convention and it's not a popular one).
The rest is very doable. We can check the existence of such file, create it if it doesn't exist, move the declaration here and eventually import whatever dependency needs to be (types, mostly).
🤔 Thinking about how to "improve" the existing behavior, I guess we could prompt the user to ask whether they want to extract the interface in the same file or another. Default would be the existing behavior (same file), but you can quickly pick "new file" and then be prompted with the interface name. That should keep the UX smooth.
All good ideas. The only reason I suggested a separate command option is to streamline the process for my typical workflow. However, even if a user had to choose an option for file, it's faster than the manual work I have to do with the current behavior. (Which is WAY better than other automated tools I've tried and infinitely better than doing it manually.)
Describe what's missing
Add a command to extract a class interface to file.
How would it work
The command would take the output from the existing Extract Interface command and rather than placing the extraction at the bottom of the current file, it would create a new file and place the extracted interface there.
Expected behavior
The name of the extraction file should follow general interface filename convention: IClassName.ts
The name of the extracted interface should follow the same convention: IClassName
The interface declaration should be prefixed with the
export
keyword:export interface IClassName {...}
Any dependent imports should be added to the top of the file before the export interface
An error notification should display if a file of the same name already exists: "Interface file already exists."
The text was updated successfully, but these errors were encountered: