docs: add guide for working with syntax trees in TypeScript#36
docs: add guide for working with syntax trees in TypeScript#36ChristianMurphy wants to merge 9 commits intounifiedjs:mainfrom
Conversation
b27601c to
a981e39
Compare
wooorm
left a comment
There was a problem hiding this comment.
Great start! I think this covers the things that TS folks will wonder about and we can link to from issues.
Some initial small suggestions inline, then the following two points:
-
Running
npm installandnpm run formatwill check grammar/spelling/punctuation and the like. One example is I see a couple long, complex sentences, that that should warn about.npm run generateshould also work, without crawling, to preview the page. -
The code examples seem to not match this projects style. I have Atom set up to format with xo and prettier on save, so what I do is to save e.g. a
.tsextension asexample.ts, and copy the formatted result into the markdown.
Finally, there are many things yelling for attention in this guide currently: casing, links, headings, a lot of inline code, a lot of fenced code. In comparison, very few things are just plain prose. I think it’s good to pass through the text again to highlight the important parts (for the user, in each section) with inline code/links, and lowlight some other parts!
|
Should we wait DefinitelyTyped/DefinitelyTyped#54413 first so that the guide could be better to use generic types? |
|
@JounQin What would that change in this guide? |
|
@wooorm Guide to use generic types for better // before
export interface StringLiteral extends Literal {
value: string
}
// after
export interface StringLiteral extends Literal<string> {
}
// or
export type StringLiteral = Literal<string> |
|
Such, or similar, behavior is not mentioned in this guide, so I don’t see a need to wait for it? As I understand it, 54413 focusses on |
|
It can also be used by end user for simple usage. // before
declare const parent: Parent
const children = parent.children as Literal[] // error now
// after
declare const parent: Parent<Literal>
const children = parent.children // alreay `Literal[]` |
|
I don‘t see any practical reasons for end users to do that. To repeat from the other threads, I don’t think end users should do that. |
|
On the conversation earlier between @JounQin and me: I can see some value in explaining how to type custom nodes. Especially with @remcohaszing new registry’s |
Done
I checked the examples with prettier and XO using a new file and
I'm confused by this.
🤔 do you see this being a part of the basic syntax trees with TypeScript guide? |
Maybe. At least the discussions shows me that there’s something somewhere we should explain.
I mean to lowlight most, and highlight less. But definitely highlight certain important parts. |
Specifically I saw the indent at 4 instead of 2 spaces? |
… in jsdoc, limit line length
Updated to lessen amount of inline
Updated in 0119321 and b4423ee, double quotes remain in jsx examples as prettier/xo appear to still prefer them in that context. |
|
Nice! I’ll do another whole review tomorrow! |
|
To @JounQin's points in #36 (comment) and #36 (comment) I see both of those potentially having value. My intent with this first guide is focused more on people interested in adopting unified with remark. I could see several related topic focused more on maintaining or customizing unified, having their own recipes or guides.
|
|
Another idea, I'm not quite sure where to slot this in the guide, would be covering some recommended tsconfig.json options.
|
wooorm
left a comment
There was a problem hiding this comment.
Nice!!!
Alright, I did a pass of the whole document.
I do think my suggestions are useful compared to the current text, but they’re perfect: please take them and amend them where appropriate
Co-authored-by: Titus <tituswormer@gmail.com>
|
#36 (comment), closing this in favor of #37 |
Initial checklist
Description of changes
This provides an overview of the packages around the Unified ecosystem that makes working with syntax trees easier.
Specifically focusing on:
Nodes to specific syntax typesrendered version
📓 This does not cover how to type a
Pluginin TypeScript or TypeScript+JSDoc, my current thought is that would be small enough and distinct enough to be recipe(s)