-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refactor to use TypeScript @import
JSDoc tags
#2498
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,20 +2,20 @@ | |
/* @jsxImportSource react */ | ||
|
||
/** | ||
* @typedef {import('@wooorm/starry-night').Grammar} Grammar | ||
* @typedef {import('estree').Node} EstreeNode | ||
* @typedef {import('estree').Program} Program | ||
* @typedef {import('hast').Nodes} HastNodes | ||
* @typedef {import('hast').Root} HastRoot | ||
* @typedef {import('mdast').Nodes} MdastNodes | ||
* @typedef {import('mdast').Root} MdastRoot | ||
* @typedef {import('mdast-util-mdx-jsx').MdxJsxAttribute} MdxJsxAttribute | ||
* @typedef {import('mdast-util-mdx-jsx').MdxJsxAttributeValueExpression} MdxJsxAttributeValueExpression | ||
* @typedef {import('mdast-util-mdx-jsx').MdxJsxExpressionAttribute} MdxJsxExpressionAttribute | ||
* @typedef {import('mdx/types.js').MDXModule} MDXModule | ||
* @typedef {import('react-error-boundary').FallbackProps} FallbackProperties | ||
* @typedef {import('unified').PluggableList} PluggableList | ||
* @typedef {import('unist').Node} UnistNode | ||
* @import {Grammar} from '@wooorm/starry-night' | ||
* @import {Node as EstreeNode, Program} from 'estree' | ||
* @import {Nodes as HastNodes, Root as HastRoot} from 'hast' | ||
* @import {Nodes as MdastNodes, Root as MdastRoot} from 'mdast' | ||
* @import { | ||
MdxJsxAttribute, | ||
MdxJsxAttributeValueExpression, | ||
MdxJsxExpressionAttribute | ||
* } from 'mdast-util-mdx-jsx' | ||
* @import {MDXModule} from 'mdx/types.js' | ||
* @import {ReactNode} from 'react' | ||
* @import {FallbackProps} from 'react-error-boundary' | ||
* @import {PluggableList} from 'unified' | ||
* @import {Node as UnistNode} from 'unist' | ||
*/ | ||
|
||
/** | ||
|
@@ -35,7 +35,7 @@ | |
* OK. | ||
* @property {true} ok | ||
* Whether OK. | ||
* @property {JSX.Element} value | ||
* @property {ReactNode} value | ||
* Result. | ||
* | ||
* @typedef {EvalNok | EvalOk} EvalResult | ||
|
@@ -315,7 +315,7 @@ function Playground() { | |
const scope = formatMarkdown ? 'text.md' : 'source.mdx' | ||
// Cast to actual value. | ||
const compiledResult = /** @type {EvalResult | undefined} */ (evalResult) | ||
/** @type {JSX.Element | undefined} */ | ||
/** @type {ReactNode | undefined} */ | ||
let display | ||
|
||
if (compiledResult) { | ||
|
@@ -579,9 +579,9 @@ function Playground() { | |
|
||
/** | ||
* | ||
* @param {Readonly<FallbackProperties>} properties | ||
* @param {Readonly<FallbackProps>} properties | ||
* Properties. | ||
* @returns {JSX.Element} | ||
* @returns {ReactNode} | ||
* Element. | ||
*/ | ||
function ErrorFallback(properties) { | ||
|
@@ -601,7 +601,7 @@ function ErrorFallback(properties) { | |
/** | ||
* @param {DisplayProperties} properties | ||
* Properties. | ||
* @returns {JSX.Element} | ||
* @returns {ReactNode} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better in separate PRs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. One thing let to another. IMO this is fine to keep as-is now. |
||
* Element. | ||
*/ | ||
function DisplayError(properties) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* @typedef {import('vfile').Data} Data | ||
* @import {Data} from 'vfile' | ||
*/ | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
{ | ||
/** | ||
* @import {Item} from '../_component/sort.js | ||
*/ | ||
|
||
/** | ||
* @typedef Props | ||
* @property {Item} navigationTree | ||
*/ | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. <3 |
||
|
||
import assert from 'node:assert/strict' | ||
import {BlogGroup} from '../_component/blog.jsx' | ||
|
||
|
@@ -16,11 +27,6 @@ The latest news about MDX. | |
|
||
{ | ||
(function () { | ||
/** | ||
* @typedef {import('../_component/sort.js').Item} Item | ||
*/ | ||
|
||
/** @type {Item} */ | ||
const navigationTree = props.navigationTree | ||
const category = navigationTree.children.find(function (item) { | ||
return item.name === '/blog/' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
{ | ||
/** | ||
* @import {Item} from '../_component/sort.js | ||
*/ | ||
|
||
/** | ||
* @typedef Props | ||
* @property {Item} navigationTree | ||
*/ | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like this it’s also more similar to frontmatter 🤔 |
||
|
||
import assert from 'node:assert/strict' | ||
import {NavigationGroup} from '../_component/nav.jsx' | ||
|
||
|
@@ -15,11 +26,6 @@ and some background information. | |
|
||
{ | ||
(function () { | ||
/** | ||
* @typedef {import('../_component/sort.js').Item} Item | ||
*/ | ||
|
||
/** @type {Item} */ | ||
const navigationTree = props.navigationTree | ||
const category = navigationTree.children.find(function (item) { | ||
return item.name === '/community/' | ||
|
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.
Using asterisks for multiline imports caused problems, but not in the TypeScript playground. I’m looking into this.
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.
microsoft/TypeScript#59011
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.
I’d work around it by not wrapping 🤷♂️
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.
I considered that. It would be ok’ish for this line, but some others would become extremely long. I prefer to keep it like this TBH, keeping the max length at approximately what we use for Prettier.