-
Notifications
You must be signed in to change notification settings - Fork 7
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
add typescript support #13
Conversation
I don't have experience with |
No I'm not - Will need to check. This was my first guess, as we are using |
I'm also not sure that the Either way, this is super cool, thank you — would love to see this land! |
If you mean "replace Acorn in Svelte with TS-Estree" - it's probably going to be slower: typescript-eslint/typescript-eslint#1003 |
I fiddled around with it a bit last night and concluded it probably wouldn't work for us because there's no equivalent of |
Regarding the /** @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} test */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is way better! But sadly, not good. eslint
and @typescript-eslint/types
handle comments in a special way (globally) and therefore we are currently left with 9 type errors regarding comments.
But I think we should be able to find a workaround here.
Edit: And the autocompletion is painfully slow. Will check where this is coming from
Edit 2: Seems to be related to our own types.
type NodeOf<T extends string, X> = X extends { type: T } ? X : never;
type Handler<T> = (node: T, state: State) => undefined;
export type Handlers = {
[K in AST_NODE_TYPES]: Handler<NodeOf<K, TSESTree.Node>>;
};
Are you aware of any "full typescript feature list" so that we can see which features we are still missing? I'm currently trying to work things out with the typescript docs, but that seems pretty hard. If not, do you maybe have typescript file in mind, that we can use to determine if we are printing the same output? From the top of my head, here is what we already have / what's missing:
I don't think this PR should necessarily implement "all" of typescript. We should probably cover the most common use-cases and add the rest later on a as-needed basis. |
|
I gave Edit: Additionaly they seem to mix Functionality wise this PR is ready in my opinion (expect the two open conversations above). Typing wise, there are still major problems as described above. To put things into numbers: On That's why im not undrafting this PR at this point |
Undrafted, as this is completed functionality wise. To sumarize a lot of the previous comments:
If we can fix the review comment above and we can agree on the following thing, I think we are good to go.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some small chores while studying your changes
GitHub discussions don't create mentions, so I'll create one. This case would help improve the current state of the |
this is incredible — thank you everyone, and apologies for the delay in merging |
Guys, the internet is broken now 🥹 |
More context on @korywka 's comment: |
Also getting issues due to this |
Closes #10
Goal:
Provide a tool that can properly print svelte-ast including their appropriate JS / TS
Relates xeho91/svelte-ast-print#86
Relates svelte-add/svelte-add#193 / svelte-add/svelte-add#507
Previous attempt, not invoking
esrap
: xeho91/svelte-ast-print#90 (tried usingrecast
, failed)State of this PR
This is a POC. My main goal was to make the failing tests of
svelte-ast-print
pass. I wrote a few tests for some basic functionality, but there are 100% a lot more things we might need to think about.Notes
We might need to consider usingDone by usingast-types
instead of@types/estree
, asast-types
provides correct types for type annotations.@types/estree
explains how they could work in the documentation, but do not actually the provides for that. All TS related properties are untyped, thus the many// @ts-expect-error
comments@typescript-eslint/types
acorn-typescript
under the hood, same assvelte
Todos
ast-types
above)