vscode-auto-close-tag
vscode-auto-close-tag copied to clipboard
TypeScript Generics: Adds closing "Tag" to type specifier
Using VS Code and editing a TS File and using generics, the plugin is adding a closing HTML-Tag to the generics type specifier, e.G.:
clicked = new EventEmitter<string></string>()
It's okay for Angular2 TS files containing inline HTML templates, but it should somehow detect if I am editing a generic class instantiation.
Edit:
Hi @AncientGrief , currently the extension has not supported this scenario. A quick workaround is to only enable auto-close-tag on certain languages. In VS Code, File->Preferences->User Settings, open the settings.json. Then add config like below:
{
"auto-close-tag.activationOnLanguage": [
"html",
"xml",
"javascript",
"javascriptreact",
"typescriptreact"
]
}
Thus, the auto-close-tag will enabled on .tsx
file and disabled on .ts
file. Let me know whether it works for you.
@formulahendry I'm having this exact same issue. I use TypeScript with React, which means all my tags are living with my types, and I cannot just turn off Auto Close in my '.tsx' files.
It's a very nice extension, nevertheless. Thank you for the effort.
Speaking of which, I find that the "Sublime 3" mode seems an acceptable workaround me though...
@andyshuhsin , thanks for your feedback. Yes, Sublime Text Mode would be one of the workaround. Also, you could use Alt+.
(Command+Alt+.
for Mac) to trigger close tag manually.
I see the same thing with flow annotations in .jsx files. I have basically gotten used to hitting undo (cmd-z) to clear the close tag after it's auto-generated (on mac).
I've just disabled on TS. I don't write many tags there and I do write a lot of generics. Still a time-saving extension, and free -- so I can't complain. Would be neat if it could only complete tags in strings for languages like TS and JS.
I have the same issue using Flow.
Would this issue be addressed (without workarounds)?
@warmbowski ,very witty.😁
same here, June 2019,..
I'm seeing this issue with JSX generics as well, which lead me to disable the plugin:
for example using Apollo Query, you can write generic JSX as such:
<Query<{name:string}>>
</Query>
the plugin constantly attempts to rename the closing tag with the generic, causing errors. As far as I can tell there isn't a way out of this issue currently?
I see the same thing with flow annotations in .jsx files. I have basically gotten used to hitting undo (cmd-z) to clear the close tag after it's auto-generated (on mac).
Can confirm ctrl+z works as expected here on Windows.
Any updates here? Can't this be made configurable?
It'd be great if there's an option for TS users to config whether close tags or not depending on what the tag name is. For instance <T>
Array<string>
, etc..
Sublime mode can be the plan B, but it's uncomfortable still from the fact that you still need to type additional "</". Seems like pressing Cmd-z(MAC) is simple-er
Thanks for the great extension thou.
Apparently it's best to just disable this extension altogether. The included typescript extension for vscode already autocloses tags in JSX/TSX. So if you just need the auto-close-tag
extension for that you can disable it.
Relevant settings are: javascript.autoClosingTags
and typescript.autoClosingTags
.
@formulahendry why still include javascript and typescript within the defaults? Unless I've somehow retained settings from 5 years ago.
Anyway, removing the languages as shown above worked.
I just ran into this problem and the solution is to simply uninstall the Auto Close Tag
extension - you probably won't need it. VSCode auto closes tags by itself and you will no longer be having the problem of generic type definitions in Typescript files being auto-closed too. (Then you also won't need any settings for auto-close-tag
.)
I had the same problem, so I had to shut it down<Auto Close Tag>,
Hi @AncientGrief , currently the extension has not supported this scenario. A quick workaround is to only enable auto-close-tag on certain languages. In VS Code, File->Preferences->User Settings, open the settings.json. Then add config like below:
{ "auto-close-tag.activationOnLanguage": [ "html", "xml", "javascript", "javascriptreact", "typescriptreact" ] }
Thus, the auto-close-tag will enabled on
.tsx
file and disabled on.ts
file. Let me know whether it works for you.
Hi @formulahendry , I just configured the following configurations in the settings.json file, but I still encounter the issue shown in the attached GIF file when using TypeScript syntax in the script tag of my Vue file. Is there any solution to this?