-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch @mdx-js/mdx to stop generating invalid JSX when
used with remark-shiki-twoslash. @calebeby, who provided the workaround, is the king. - mdx-js/mdx#2123 - mdx-js/mdx#2112
- Loading branch information
Showing
4 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
diff --git a/lib/plugin/recma-jsx-rewrite.js b/lib/plugin/recma-jsx-rewrite.js | ||
index 1e82a1e41b18b16cb5d2f2a66b07e2d9544c55db..eb5286a273f095bedb693ec587917d6162164108 100644 | ||
--- a/lib/plugin/recma-jsx-rewrite.js | ||
+++ b/lib/plugin/recma-jsx-rewrite.js | ||
@@ -387,11 +387,13 @@ export function recmaJsxRewrite(options = {}) { | ||
}) | ||
} | ||
|
||
- statements.push({ | ||
- type: 'VariableDeclaration', | ||
- kind: 'const', | ||
- declarations | ||
- }) | ||
+ if (declarations.length > 0) { | ||
+ statements.push({ | ||
+ type: 'VariableDeclaration', | ||
+ kind: 'const', | ||
+ declarations | ||
+ }) | ||
+ } | ||
} | ||
|
||
/** @type {string} */ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
We're using [Shiki Twoslash](https://shikijs.github.io/twoslash/) to highlight | ||
TypeScript and JavaScript code. | ||
` | ||
|
||
```ts twoslash | ||
// @module: esnext | ||
// @filename: maths.ts | ||
export function absolute(num: number) { | ||
if (num < 0) return num * -1; | ||
return num; | ||
} | ||
// @filename: index.ts | ||
import { absolute } from "./maths"; | ||
const value = absolute(-1); | ||
``` |