Closed timsofteng closed 1 year ago
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.
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?
@rafamadriz any news about it?
can you please extande typescript.json
with javascript.json
?
@rafamadriz any news about it? I've can you please extande
typescript.json
withjavascript.json
?
So, you want js snippets in ts? Or ts snippets in js file?
@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.
You can make a pr to fix that :))
I actually think I have a fix for this
Edit: PR soon (hopefully) :sunglasses:
Second edit: Taking a bit longer than planned due to some life stuff. But should be up for review this week
nice nice
@OkelleyDevelopment Hello! Any updates around this issue?
@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:
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 :sweat_smile: )
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 :thinking:
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 :sweat:
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" })
Hello. I've notices you drop mixing sources for some complex filetypes (ts and tsx in my case). https://github.com/rafamadriz/friendly-snippets/issues/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
iscl
and in ts snippets itslog
. And so on.