Skip to content
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

Extension is auto-closing generic type parameters in TypeScript #24

Closed
ChuckkNorris opened this issue Jan 22, 2017 · 8 comments
Closed
Labels

Comments

@ChuckkNorris
Copy link

ChuckkNorris commented Jan 22, 2017

When using type parameters or generics, this extension will add another closing "tag" even though it's not HTML at all.

e.g.

myMethod<T>() { } // When typing, <T></T> is added

doStuff() {
   myMethod<Person>(); // When typing, it adds </Person>
   myMethod<any>(); // When typing, an ending </any> tag is added
}

Now I could add every single type/class name to the "auto-close-tag.excludedTags" list, but that would be quite cumbersome.

Ideally, there would be a way to disable this extension for all *.ts file types. Is there a better way to prevent auto-close in my TypeScript code?

@formulahendry
Copy link
Owner

Hi @ChuckkNorris , you could set the languages that the auto-close-tag will be activated,
In VS Code, File->Preferences->User Settings, to open the settings.json. Then add config like below:

{
    "auto-close-tag.activationOnLanguage": [
        "javascript",
        "javascriptreact",
        "html",
        "xml",
        "php"
    ]
}

Refer to this for the full list of Language Identifiers.
Let me know if this works for you.

@ChuckkNorris
Copy link
Author

Exactly what I was looking for - thanks for the help.
I'll read the docs more carefully next time.

@lucascyrne
Copy link

So if I want auto-close-tag on jsx DOM tags but at the same time, deactivate it when closing generic typescript types. simply can't I? @formulahendry

thanks in advance.

@kellyrmilligan
Copy link

what @lucascyrne brings up is exactly how I landed here from google.

@lbfalvy
Copy link

lbfalvy commented Nov 19, 2022

All I want for Christmas is a setting to enable this for .tsx files but not for .ts files

@rezoled
Copy link

rezoled commented Aug 15, 2023

The issue is not closed. When writing angular code I want to get auto close in templates, but not in the typescript block of the same file.

@tincho
Copy link

tincho commented Jan 19, 2024

when file type is "typescriptreact"

the extension could only activate autoclosing if inside a return statement

of course it's not a perfect fix, since JSX may be in a variable or non-return statement

... but it would be good enough !

@fcFn
Copy link

fcFn commented Jul 7, 2024

Should be reopened so that users understand that is not solved without reading the whole thread. Thank you!

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

No branches or pull requests

8 participants