-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Addon Storysource typescript support #3253
Conversation
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.
Cool. AFAIU it will allow parsing Flow as well (at least prettier itself does it with no problem)
Yeah. they have a https://github.com/prettier/prettier/tree/master/src/language-js |
Codecov Report
@@ Coverage Diff @@
## master #3253 +/- ##
==========================================
- Coverage 35.86% 35.85% -0.01%
==========================================
Files 440 444 +4
Lines 9682 9731 +49
Branches 902 927 +25
==========================================
+ Hits 3472 3489 +17
+ Misses 5647 5627 -20
- Partials 563 615 +52
Continue to review full report at Codecov.
|
Released as |
Looks like Prettier doesn't consider those parsers a public API: they changed their exports in a minor release Can we maybe use |
Probably we should, they might break it again. Maybe to worth porting the "generic parser" as a separate repo |
Issue: acorn parser doesn't support typescript out of the box. Until now all the angular stories were parsed successfully because there was no typing in them. But if you want to add a component example into the story (I think it is useful because the user will see a real example and not only a story) the parsing breaks.
What I did
I've removed the use of acorn from the loader and used
prettier/parser-*
instead (since the addon is already dependant on prettier).In this case for a regular javascript (which is the default), we will use
prettier/parser-babylon
(according to the docs babylon is based on acorn)And for TypeScript we will use
prettier/parser-typescript
.In order to make it work with typescript, I've added a
parser
option to the loader.