-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for _not_ using JS at all
- Loading branch information
Showing
35 changed files
with
1,713 additions
and
613 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
"transform": { | ||
"^.+\\.tsx?$": "esbuild-jest" | ||
"^.+\\.tsx?$": [ | ||
"esbuild-jest", | ||
{ | ||
sourcemap: true, | ||
loaders: { | ||
'.spec.ts': 'tsx' | ||
} | ||
} | ||
] | ||
} | ||
}; |
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
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
18 changes: 18 additions & 0 deletions
18
packages/gatsby-remark-shiki-twoslash/test/fixtures/generics.md
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,18 @@ | ||
## Generics in the LSP | ||
|
||
```ts twoslash | ||
type A<B> = { | ||
str: string | ||
b: B | ||
} | ||
``` | ||
## String union in the Generics in the LSP | ||
```ts twoslash | ||
|
||
type A<B> = { | ||
str: "one" | "two" | ||
b: B | ||
} | ||
``` |
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
68 changes: 68 additions & 0 deletions
68
packages/gatsby-remark-shiki-twoslash/test/results/generics.html
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,68 @@ | ||
<h2>Generics in the LSP</h2> | ||
<pre | ||
class="shiki twoslash lsp" | ||
style="background-color: #ffffff; color: #000000" | ||
><div class='code-container'><code><div class='line'><span style="color: #0000FF">type</span><span style="color: #000000"> </span><span style="color: #267F99"><data-lsp lsp='type A<B> = { str: string; b: B; }' >A</data-lsp></span><span style="color: #000000"><</span><span style="color: #267F99"><data-lsp lsp='(type parameter) B in type A<B>' >B</data-lsp></span><span style="color: #000000">> = { </span></div><div class='line'><span style="color: #000000"> </span><span style="color: #001080"><data-lsp lsp='(property) str: string' >str</data-lsp></span><span style="color: #000000">: </span><span style="color: #267F99">string</span></div><div class='line'><span style="color: #000000"> </span><span style="color: #001080"><data-lsp lsp='(property) b: B' >b</data-lsp></span><span style="color: #000000">: </span><span style="color: #267F99"><data-lsp lsp='(type parameter) B in type A<B>' >B</data-lsp></span></div><div class='line'><span style="color: #000000">}</span></div></code></div></pre> | ||
<h2>String union in the Generics in the LSP</h2> | ||
<pre | ||
class="shiki twoslash lsp" | ||
style="background-color: #ffffff; color: #000000" | ||
><div class='code-container'><code><div class='line'><span style="color: #0000FF">type</span><span style="color: #000000"> </span><span style="color: #267F99"><data-lsp lsp='type A<B> = { str: "one" | "two"; b: B; }' >A</data-lsp></span><span style="color: #000000"><</span><span style="color: #267F99"><data-lsp lsp='(type parameter) B in type A<B>' >B</data-lsp></span><span style="color: #000000">> = { </span></div><div class='line'><span style="color: #000000"> </span><span style="color: #001080"><data-lsp lsp='(property) str: "one" | "two"' >str</data-lsp></span><span style="color: #000000">: </span><span style="color: #A31515">"one"</span><span style="color: #000000"> | </span><span style="color: #A31515">"two"</span></div><div class='line'><span style="color: #000000"> </span><span style="color: #001080"><data-lsp lsp='(property) b: B' >b</data-lsp></span><span style="color: #000000">: </span><span style="color: #267F99"><data-lsp lsp='(type parameter) B in type A<B>' >B</data-lsp></span></div><div class='line'><span style="color: #000000">}</span></div></code></div></pre> | ||
|
||
<style> | ||
.shiki { | ||
background-color: lightgrey; | ||
padding: 8px; | ||
} | ||
|
||
.error, | ||
.error-behind { | ||
margin-left: -20px; | ||
margin-right: -12px; | ||
margin-top: 4px; | ||
margin-bottom: 4px; | ||
padding: 6px; | ||
padding-left: 14px; | ||
|
||
white-space: pre-wrap; | ||
display: block; | ||
} | ||
|
||
.error { | ||
position: absolute; | ||
background-color: #ffeeee; | ||
border-left: 2px solid #bf1818; | ||
width: 100%; | ||
|
||
display: flex; | ||
align-items: center; | ||
color: black; | ||
} | ||
|
||
.error-behind { | ||
user-select: none; | ||
color: #ffeeee; | ||
} | ||
.query { | ||
color: white; | ||
} | ||
|
||
/* To get them all hovering OOTB: .twoslash data-lsp::before { */ | ||
|
||
.twoslash data-lsp:hover::before { | ||
content: attr(lsp); | ||
position: absolute; | ||
transform: translate(0, 1rem); | ||
|
||
background-color: #3f3f3f; | ||
color: #fff; | ||
text-align: left; | ||
padding: 5px 8px; | ||
border-radius: 2px; | ||
font-family: "JetBrains Mono", Menlo, Monaco, Consolas, Courier New, | ||
monospace; | ||
font-size: 14px; | ||
white-space: pre-wrap; | ||
z-index: 100; | ||
} | ||
</style> |
112 changes: 112 additions & 0 deletions
112
packages/gatsby-remark-shiki-twoslash/test/results/generics.json
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,112 @@ | ||
[ | ||
{ | ||
"code": "type A<B> = { \n str: string\n b: B\n}", | ||
"extension": "ts", | ||
"highlights": [], | ||
"queries": [], | ||
"staticQuickInfos": [ | ||
{ | ||
"text": "type A<B> = {\n str: string;\n b: B;\n}", | ||
"docs": "", | ||
"start": 5, | ||
"length": 1, | ||
"line": 0, | ||
"character": 5, | ||
"targetString": "A" | ||
}, | ||
{ | ||
"text": "(type parameter) B in type A<B>", | ||
"docs": "", | ||
"start": 7, | ||
"length": 1, | ||
"line": 0, | ||
"character": 7, | ||
"targetString": "B" | ||
}, | ||
{ | ||
"text": "(property) str: string", | ||
"docs": "", | ||
"start": 19, | ||
"length": 3, | ||
"line": 1, | ||
"character": 4, | ||
"targetString": "str" | ||
}, | ||
{ | ||
"text": "(property) b: B", | ||
"docs": "", | ||
"start": 35, | ||
"length": 1, | ||
"line": 2, | ||
"character": 4, | ||
"targetString": "b" | ||
}, | ||
{ | ||
"text": "(type parameter) B in type A<B>", | ||
"docs": "", | ||
"start": 38, | ||
"length": 1, | ||
"line": 2, | ||
"character": 7, | ||
"targetString": "B" | ||
} | ||
], | ||
"errors": [], | ||
"playgroundURL": "https://www.typescriptlang.org/play/#code/C4TwDgpgBAggPAIQHxQLxQN5QFBT1AZ2ACcAuQkgSwDsBzXfAI3IWwF8g" | ||
}, | ||
{ | ||
"code": "\ntype A<B> = { \n str: \"one\" | \"two\"\n b: B\n}", | ||
"extension": "ts", | ||
"highlights": [], | ||
"queries": [], | ||
"staticQuickInfos": [ | ||
{ | ||
"text": "type A<B> = {\n str: \"one\" | \"two\";\n b: B;\n}", | ||
"docs": "", | ||
"start": 6, | ||
"length": 1, | ||
"line": 1, | ||
"character": 5, | ||
"targetString": "A" | ||
}, | ||
{ | ||
"text": "(type parameter) B in type A<B>", | ||
"docs": "", | ||
"start": 8, | ||
"length": 1, | ||
"line": 1, | ||
"character": 7, | ||
"targetString": "B" | ||
}, | ||
{ | ||
"text": "(property) str: \"one\" | \"two\"", | ||
"docs": "", | ||
"start": 20, | ||
"length": 3, | ||
"line": 2, | ||
"character": 4, | ||
"targetString": "str" | ||
}, | ||
{ | ||
"text": "(property) b: B", | ||
"docs": "", | ||
"start": 43, | ||
"length": 1, | ||
"line": 3, | ||
"character": 4, | ||
"targetString": "b" | ||
}, | ||
{ | ||
"text": "(type parameter) B in type A<B>", | ||
"docs": "", | ||
"start": 46, | ||
"length": 1, | ||
"line": 3, | ||
"character": 7, | ||
"targetString": "B" | ||
} | ||
], | ||
"errors": [], | ||
"playgroundURL": "https://www.typescriptlang.org/play/#code/FAFwngDgpgBAggHgEID4YF4YG8bBvmAZxACcAuGAIgHsA7KSmAHypAHdrK8CAjCpYAF8gA" | ||
} | ||
] |
Oops, something went wrong.