Skip to content

Commit 2163398

Browse files
cspotcodeJosh-Cena
andauthored
Merge docs into main for 10.7.0
* chore(website): upgrade Docusaurus, format files * remove external link icon * upgrade Docusaurus to beta.16 * fix lock * add shiki-twoslash, pick code highlighting themes, update build-readme.mjs to strip twoslash prefixes, fix a couple typos and docs mistakes found due to the above (yay), pin yarn version * linting * beta.17 * point breadcrumb home to /docs * fix prettier config * remove twoslash tsconfig renderer due to rendering bug on dark theme, and it also adds erroneous links to ts-node sub-config Co-authored-by: Andrew Bradley <[email protected]> Co-authored-by: Joshua Chen <[email protected]>
1 parent 0792067 commit 2163398

16 files changed

+3971
-5666
lines changed

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
!/scripts
77
!/src
88
!/tests
9+
!/website
10+
/website/.docusaurus
11+
/website/docs
12+
/website/readme-sources
13+
/website/static
914
tests/main-realpath/symlink/tsconfig.json
1015
tests/throw error.ts
1116
tests/throw error react tsx.tsx

website/docs/module-type-overrides.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CommonJS or ESM. Node supports similar overriding via `.cjs` and `.mjs` file ex
1717

1818
The following example tells ts-node to execute a webpack config as CommonJS:
1919

20-
```json title=tsconfig.json
20+
```json title="tsconfig.json"
2121
{
2222
"ts-node": {
2323
"transpileOnly": true,

website/docs/recipes/ava.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Assuming you are configuring AVA via your `package.json`, add one of the followi
88

99
Use this configuration if your `package.json` does not have `"type": "module"`.
1010

11-
```json title"package.json"
11+
```json title="package.json"
1212
{
1313
"ava": {
1414
"extensions": [
@@ -25,7 +25,7 @@ Use this configuration if your `package.json` does not have `"type": "module"`.
2525

2626
This configuration is necessary if your `package.json` has `"type": "module"`.
2727

28-
```json title"package.json"
28+
```json title="package.json"
2929
{
3030
"ava": {
3131
"extensions": {

website/docs/troubleshooting.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ the [tsconfig `"target"` option](https://www.typescriptlang.org/tsconfig#target)
7171

7272
For example, `node` 12 does not understand the `?.` optional chaining operator. If you use `"target": "esnext"`, then the following TypeScript syntax:
7373

74-
```typescript
74+
```typescript twoslash
75+
export {};
76+
var foo: {bar: string} | undefined;
77+
// ---cut---
7578
const bar: string | undefined = foo?.bar;
7679
```
7780

website/docs/types.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ Example project structure:
2828

2929
Example module declaration file:
3030

31-
```typescript
31+
```typescript twoslash
3232
declare module '<module_name>' {
3333
// module definitions go here
3434
}
3535
```
3636

3737
For module definitions, you can use [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping):
3838

39-
```json
39+
```json title="tsconfig.json"
4040
{
4141
"compilerOptions": {
4242
"baseUrl": ".",
@@ -49,9 +49,11 @@ For module definitions, you can use [`paths`](https://www.typescriptlang.org/doc
4949

5050
An alternative approach for definitions of third-party libraries are [triple-slash directives](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html). This may be helpful if you prefer not to change your TypeScript `compilerOptions` or structure your custom type definitions when using `typeRoots`. Below is an example of the triple-slash directive as a relative path within your project:
5151

52-
```typescript
53-
/// <reference types="./types/untyped_js_lib" />
54-
import UntypedJsLib from "untyped_js_lib"
52+
```typescript twoslash
53+
/// <reference path="./types/untyped_js_lib" />
54+
import {Greeter} from "untyped_js_lib"
55+
const g = new Greeter();
56+
g.sayHello();
5557
```
5658

5759
**Tip:** If you _must_ use `files`, `include`, or `exclude`, enable `--files` flags or set `TS_NODE_FILES=true`.

website/docs/usage.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ ts-node-esm script.ts
3232

3333
## Shebang
3434

35-
```typescript
35+
```typescript twoslash
3636
#!/usr/bin/env ts-node
3737

3838
console.log("Hello, world!")
3939
```
4040

4141
Passing options via shebang requires the [`env -S` flag](https://manpages.debian.org/bullseye/coreutils/env.1.en.html#S), which is available on recent versions of `env`. ([compatibility](https://github.com/TypeStrong/ts-node/pull/1448#issuecomment-913895766))
4242

43-
```typescript
43+
```typescript twoslash
4444
#!/usr/bin/env -S ts-node --files
4545
// This shebang works on Mac and Linux with newer versions of env
4646
// Technically, Mac allows omitting `-S`, but Linux requires it
4747
```
4848

4949
To write scripts with maximum portability, [specify all options in your `tsconfig.json`](./configuration#via-tsconfigjson-recommended) and omit them from the shebang.
5050

51-
```typescript
51+
```typescript twoslash
5252
#!/usr/bin/env ts-node
5353
// This shebang works everywhere
5454
```

website/docusaurus.config.js

+76-23
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
// //isCloseable: false, // Defaults to `true`.
2020
// },
2121
colorMode: {
22-
respectPrefersColorScheme: true
22+
respectPrefersColorScheme: true,
2323
},
2424
navbar: {
2525
title: 'ts-node',
@@ -61,6 +61,20 @@ module.exports = {
6161
},
6262
],
6363
},
64+
metadata: [
65+
{
66+
name: 'msapplication-TileColor',
67+
content: '#2b5797',
68+
},
69+
{
70+
name: 'msapplication-config',
71+
content: '/ts-node/img/favicon/browserconfig.xml',
72+
},
73+
{
74+
name: 'theme-color',
75+
content: '#ffffff',
76+
},
77+
],
6478
// footer: {
6579
// style: 'dark',
6680
// links: [
@@ -99,23 +113,14 @@ module.exports = {
99113
// // copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`,
100114
// },
101115
prism: {
102-
// for syntax highlighting
103-
// additionalLanguages: ['powershell'],
116+
// Note: these themes are ignored due to using shiki-twoslash
117+
theme: require('prism-react-renderer/themes/vsLight'),
118+
darkTheme: require('prism-react-renderer/themes/vsDark'),
104119
},
105120
algolia: {
106-
apiKey: 'c882a0a136ef4e15aa99db604280caa6',
121+
appId: 'BYGNLKSCOV',
122+
apiKey: '74ac2b781b0cf603c2f1b5e4f44e1c69',
107123
indexName: 'ts-node',
108-
109-
// Optional: see doc section below
110-
// contextualSearch: true,
111-
112-
// Optional: see doc section below
113-
// appId: 'YOUR_APP_ID',
114-
115-
// Optional: Algolia search parameters
116-
// searchParameters: {},
117-
118-
//... other Algolia params
119124
},
120125
},
121126
presets: [
@@ -124,19 +129,67 @@ module.exports = {
124129
{
125130
docs: {
126131
sidebarPath: require.resolve('./sidebars.js'),
127-
editUrl:
128-
'https://github.com/TypeStrong/ts-node/edit/docs/website/',
132+
editUrl: 'https://github.com/TypeStrong/ts-node/edit/docs/website/',
129133
},
130-
// blog: {
131-
// showReadingTime: true,
132-
// // Please change this to your repo.
133-
// editUrl:
134-
// 'https://github.com/facebook/docusaurus/edit/master/website/blog/',
135-
// },
134+
blog: false,
136135
theme: {
137136
customCss: require.resolve('./src/css/custom.css'),
138137
},
139138
},
140139
],
140+
[
141+
'docusaurus-preset-shiki-twoslash',
142+
{
143+
// https://github.com/shikijs/twoslash/blob/main/packages/shiki-twoslash/README.md#user-settings
144+
145+
// langs: ["shell", "typescript", "javascript", "ts", "js", "tsx", "jsx", "json", "jsonc"],
146+
includeJSDocInHover: true,
147+
148+
themes: ['github-light', 'nord'],
149+
150+
// VSCode default
151+
// themes: ["light-plus", "dark-plus"],
152+
153+
// Other options
154+
// themes: ["min-light", "nord"],
155+
// themes: ["min-light", "min-dark"],
156+
// themes: ["github-light", "github-dark"],
157+
// themes: ["solarized-light", "solarized-dark"],
158+
},
159+
],
160+
],
161+
// Misleading API that probably will be refactored in Docusaurus, but this is
162+
// simply a list of <link> tags
163+
stylesheets: [
164+
{
165+
rel: 'apple-touch-icon',
166+
sizes: '180x180',
167+
href: '/ts-node/img/favicon/apple-touch-icon.png',
168+
},
169+
{
170+
rel: 'icon',
171+
type: 'image/png',
172+
sizes: '32x32',
173+
href: '/ts-node/img/favicon/favicon-32x32.png',
174+
},
175+
{
176+
rel: 'icon',
177+
type: 'image/png',
178+
sizes: '16x16',
179+
href: '/ts-node/img/favicon/favicon-16x16.png',
180+
},
181+
{
182+
rel: 'manifest',
183+
href: '/ts-node/img/favicon/site.webmanifest',
184+
},
185+
{
186+
rel: 'mask-icon',
187+
href: '/ts-node/img/favicon/safari-pinned-tab.svg',
188+
color: '#5bbad5',
189+
},
190+
{
191+
rel: 'shortcut icon',
192+
href: '/ts-node/img/favicon/favicon.ico',
193+
},
141194
],
142195
};

website/package.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"build-readme": "./scripts/build-readme.mjs"
1414
},
1515
"dependencies": {
16-
"@docusaurus/core": "2.0.0-alpha.75",
17-
"@docusaurus/preset-classic": "2.0.0-alpha.75",
18-
"@docusaurus/theme-search-algolia": "^2.0.0-alpha.75",
19-
"@mdx-js/react": "^1.6.21",
16+
"@docusaurus/core": "2.0.0-beta.17",
17+
"@docusaurus/preset-classic": "2.0.0-beta.17",
18+
"@mdx-js/react": "^1.6.22",
2019
"@types/js-yaml": "^4.0.0",
2120
"clsx": "^1.1.1",
21+
"docusaurus-preset-shiki-twoslash": "^1.1.36",
2222
"js-yaml": "^4.0.0",
23-
"react": "^16.8.4",
24-
"react-dom": "^16.8.4",
23+
"react": "^17.0.2",
24+
"react-dom": "^17.0.2",
2525
"remark": "^13.0.0",
2626
"remark-behead": "^2.3.3",
2727
"remark-frontmatter": "^3.0.0",
@@ -42,5 +42,10 @@
4242
"last 1 firefox version",
4343
"last 1 safari version"
4444
]
45+
},
46+
"packageManager": "[email protected]",
47+
"volta": {
48+
"extends": "../package.json",
49+
"yarn": "1.22.17"
4550
}
4651
}

0 commit comments

Comments
 (0)