Add support for TS 4.9 and `satisfies` operator
Closed this issue ยท 8 comments
Describe the bug
I receive an error when attempting to use Abracadabra in a TypeScript file which uses the satisfies
operator from TS 4.9. Docs for that feature.
How to reproduce
I was attempting to use the inline variable
helper in a TS file that contained satisfies
. If I comment out the satisfies
part, the helper runs just fine.
Expected behavior
Expect the AST to be parsed correctly with satisfies
included in a file.
Screenshots
๐ I'm sorry, something went wrong: I can't build the AST from the source code. This may be due to a syntax error that you can fix. Here's what went wrong: Missing semicolon. (128:1)
Additional information
- Version of the extension impacted: v6.17.0
Aha yes, thanks for reporting @byronwall, and sorry for that!
I think this has been solved with 47d16eb but I haven't released it yet. I'll create a test to verify it's fixed, then make a new extension release.
Thanks again!
Actually, I had to upgrade other packages to make it work. So, thanks @byronwall!
I confirm this is working fine now. Will cut a release by the end of the week.
@all-contributors please add byronwall for bugs
I've put up a pull request to add @byronwall! ๐
@nicoespeon, thanks for the quick response. It appears the same file is causing a new (but seemingly related) error with the new v6.18.2. If you want a new issue, I can create one.
The error below is resolved same as above: comment out the satisfies XXX
after an object definition. When commented, the error goes away and the refactor works as expected.
I now receive the error below in the same file:
๐ I'm sorry, something went wrong: I can't build the AST from the source code. This may be due to a syntax error that you can fix. Here's what went wrong: did not recognize object of type "TSSatisfiesExpression"
@byronwall oh, interesting. Something seems to be going on indeed. Ideally, I would need a test to repro this.
Is it just for "Inline Variable" or actually any refactoring in that file throws the same error? (I bet on the latter)
Would you have a small snippet that can reproduce this issue? That would help me the most here.
@nicoespeon, I will pare down my actual file and see if I can repro.
In the bad file, I was not able to see any of the Abracadabra quick fixes when I did CTRL+.
on an item that should have them. I then forced the Inline Variable
to run by using the command palette. That's when it gave the error message posted above.
My first simple attempt at causing the error worked just fine. That is, the issue is not simply the satisfies
operator, but something more complicated. I'll reply later today or next week when I get minute to rework the actual file. Thanks again for the quick responses.
// this code worked fine for producing the quick fix menu and `inline variable` on BobbysTwin
type Person = {
name: string;
age: number;
};
const Bobby = {
name: "Bobby",
age: 20,
} satisfies Person;
const BobbysTwin = Bobby;
console.log(BobbysTwin.name); // Bobby
@byronwall I'm gonna close this issue again. Feel free to create a new one if you can come up with a repro.
It's fine if your repro isn't minimal. It could be your actual code but somehow obfuscated. As long as you have a snippet of code I can play with, that will be good enough for me to identify the issue and fix it. At this point though, everything looks good to me with the satisfies operator ๐
Thanks!