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

Extend typescript snippets due to #88 changes #105

Closed
timsofteng opened this issue Dec 15, 2021 · 12 comments
Closed

Extend typescript snippets due to #88 changes #105

timsofteng opened this issue Dec 15, 2021 · 12 comments
Labels
enhancement New feature or request information and testing needs more information and testing

Comments

@timsofteng
Copy link

Hello. I've notices you drop mixing sources for some complex filetypes (ts and tsx in my case).
#88

So now I should invoke additional command to mix js and ts snippets. But i guess typescript still js. It's not a framework or something like that. And js snippets still totally relevant.
May you please copy js snippets into typescript's json to make it consistent?
E.g in js snippets console.log is cl and in ts snippets its log. And so on.

@rafamadriz
Copy link
Owner

Hey, thanks for reporting this.

Is typescript the exact same as JavaScript ? I don't work with typescript so I'm not sure, I know they are almost the same but I thought there were some minor differences in the syntax. I can make all the typescript snippets be the same as javascript but I need to be sure that it's not going to bring some problems where some snippets are not proper typescript syntax, or maybe some typescript exclusive snippets are deleted.

@koengommers
Copy link

I've run into a similar thing where I want to use the javascript snippets in typescript. All javascript is valid typescript. There are some situations where a type needs to be added, but it should be fine to have the javascript snippets available in typescript. The snippets in react.json and react-ts.json also seem to be identical.

What's the best way to make the javascript snippets available when filetype is typescript?

@timsofteng
Copy link
Author

timsofteng commented Apr 18, 2022

@rafamadriz any news about it?
can you please extande typescript.json with javascript.json?

@bryant-the-coder
Copy link
Collaborator

@rafamadriz any news about it? I've can you please extande typescript.json with javascript.json?

So, you want js snippets in ts? Or ts snippets in js file?

@timsofteng
Copy link
Author

@bryant-the-coder
We need js snippets in ts.
The main idea is to have same js base snippets for all js-like files (ts, tsx, jsx) with their own snippets additionally.
Take a look at tsx and js snippets. There are a lot of differents in names in same snippets.
Like console.log is cl in js but it's log in tsx. And many snippets missed in tsx comparing to js.

@bryant-the-coder
Copy link
Collaborator

You can make a pr to fix that :))

@OkelleyDevelopment OkelleyDevelopment self-assigned this May 9, 2022
@OkelleyDevelopment
Copy link
Collaborator

OkelleyDevelopment commented May 9, 2022

I actually think I have a fix for this

Edit: PR soon (hopefully) 😎

Second edit: Taking a bit longer than planned due to some life stuff. But should be up for review this week

@bryant-the-coder
Copy link
Collaborator

nice nice

@timsofteng
Copy link
Author

timsofteng commented May 27, 2022

@OkelleyDevelopment
Hello!
Any updates around this issue?

@OkelleyDevelopment
Copy link
Collaborator

@timsofteng @bryant-the-coder

Heyo !

After several weeks of trying to figure out the best approach to this issue (while ensuring we don't break other users experiences), I arrived at the solution below for getting JS snippets in TS:

image

Though I agree we could probably streamline some of these snippets, but it is a much larger endeavor than I was realizing and I do not wish to cause issues with compatibility for other users (at least not without a solid plan of what we are doing 😅 )

@OkelleyDevelopment OkelleyDevelopment removed their assignment Jun 1, 2022
@OkelleyDevelopment OkelleyDevelopment added enhancement New feature or request information and testing needs more information and testing labels Jun 1, 2022
@OkelleyDevelopment
Copy link
Collaborator

OkelleyDevelopment commented Jun 1, 2022

Maybe I'm over thinking it, but the issue I'm running into is that JS snippets are useful in TS though some people might only want the TS specific snippets which brings me back to the "just extend it with your snippet engine" answer 🤔

Edit: For those who do want both types of snippets loaded

Edit 2 on Oct. 18, 2022: I'm thinking about the best way to handle this issue. Might start a draft PR and just get input as we go.

Edit 3: If anyone has ideas, go ahead and try them. My free time seems to be fleeting at best the last few weeks 😓

@mauroporras
Copy link

This is what I did too: https://github.com/rafamadriz/friendly-snippets#add-snippets-from-a-framework-to-a-filetype

For those who want to copy and paste:

require'luasnip'.filetype_extend("typescript", { "javascript" })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request information and testing needs more information and testing
Projects
None yet
Development

No branches or pull requests

6 participants