typescript-go
typescript-go copied to clipboard
Bare TypeScript code in `@example` is interpreted as Markdown/HTML
Steps to reproduce
/**
* @example
* <Ruby text="ほっけ">𩸽</Ruby>
* <Ruby text="ビャンビャン">𰻞𰻞</Ruby>麺
*/
export const Ruby = ({ children, text }: { children: string; text: string }) => (
<ruby>
{children}
<rp>(</rp>
<rt>{text}</rt>
<rp>)</rp>
</ruby>
);
- The above file is
.tsxfile - Set
typescript.experimental.useTsgototrueinsettings.json - See the description of
Rubyby holding your mouse pointer on "Ruby" - See how
@exampleis rendered
Note: this occurs even in non-JSX .ts files (e.g. tokens are not highlighted or newlines are removed), but is not as critical as in .tsx files.
Behavior with [email protected]
Interpreted as TS code:
insiders.vscode.dev
Behavior with tsgo
Interpreted as Markdown/HTML:
Workaround: wrap it with ```tsx–````
This also works in Strada:
To fix (Strada probably adopts this method):
- Find a code block marker (
```) - If exists, treat the content as Markdown
- If missing, treat the content as TypeScript code