Skip to content

Commit 4688ade

Browse files
committed
improve css
1 parent 2bac60b commit 4688ade

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

apps/site/pages/en/learn/typescript/introduction.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,15 @@ npm add --save-dev @types/node
7070

7171
These type definitions allow TypeScript to understand Node.js APIs and provide proper type checking and autocompletion when you use functions like `fs.readFile` or `http.createServer`. For example:
7272

73-
```js
74-
import * as fs from 'fs';
75-
76-
fs.readFile('example.txt', foo, (err, data) => {
77-
// ^^^
78-
// Argument of type '"foo"' is not assignable to parameter of type …
79-
if (err) {
80-
throw err;
81-
}
82-
console.log(data);
83-
});
73+
<!-- prettier-ignore -->
74+
```ts
75+
// @noErrors
76+
/* eslint-disable */
77+
// ---cut---
78+
import fs from 'fs';
79+
80+
fs.read
81+
// ^|
8482
```
8583

8684
Many popular JavaScript libraries have their type definitions available under the `@types` namespace, maintained by the DefinitelyTyped community. This enables seamless integration of existing JavaScript libraries with TypeScript projects.

packages/rehype-shiki/src/transformers/twoslash/index.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,10 @@
1616
display: inline-block;
1717
}
1818
}
19+
20+
.twoslash-completion-list {
21+
display: block;
22+
width: auto;
23+
max-height: 100px;
24+
overflow-x: auto;
25+
}

packages/rehype-shiki/src/transformers/twoslash/index.mjs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { transformerTwoslash } from '@shikijs/twoslash';
22

3-
const compose = ({ token, popup }) => [
3+
const compose = ({ token, cursor, popup }) => [
44
{
55
type: 'element',
66
tagName: 'MDXTooltipTrigger',
7-
children: [token],
7+
children: [token || cursor],
88
properties: { className: ['twoslash-hover'] },
99
},
1010
popup,
@@ -27,6 +27,20 @@ export const twoslash = options =>
2727
errorToken: { tagName: 'MDXTooltip' },
2828
errorPopup: { tagName: 'MDXTooltipContent' },
2929
errorCompose: compose,
30+
31+
completionToken: {
32+
tagName: 'MDXTooltip',
33+
properties: {
34+
open: true,
35+
},
36+
},
37+
completionPopup: {
38+
tagName: 'MDXTooltipContent',
39+
properties: {
40+
align: 'start',
41+
},
42+
},
43+
completionCompose: compose,
3044
},
3145
},
3246
throws: false,

0 commit comments

Comments
 (0)