You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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]>
Copy file name to clipboardexpand all lines: website/docs/types.md
+7-5
Original file line number
Diff line number
Diff line change
@@ -28,15 +28,15 @@ Example project structure:
28
28
29
29
Example module declaration file:
30
30
31
-
```typescript
31
+
```typescript twoslash
32
32
declaremodule'<module_name>' {
33
33
// module definitions go here
34
34
}
35
35
```
36
36
37
37
For module definitions, you can use [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping):
38
38
39
-
```json
39
+
```json title="tsconfig.json"
40
40
{
41
41
"compilerOptions": {
42
42
"baseUrl": ".",
@@ -49,9 +49,11 @@ For module definitions, you can use [`paths`](https://www.typescriptlang.org/doc
49
49
50
50
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:
51
51
52
-
```typescript
53
-
/// <referencetypes="./types/untyped_js_lib" />
54
-
importUntypedJsLibfrom"untyped_js_lib"
52
+
```typescript twoslash
53
+
/// <referencepath="./types/untyped_js_lib" />
54
+
import {Greeter} from"untyped_js_lib"
55
+
const g =newGreeter();
56
+
g.sayHello();
55
57
```
56
58
57
59
**Tip:** If you _must_ use `files`, `include`, or `exclude`, enable `--files` flags or set `TS_NODE_FILES=true`.
Copy file name to clipboardexpand all lines: website/docs/usage.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -32,23 +32,23 @@ ts-node-esm script.ts
32
32
33
33
## Shebang
34
34
35
-
```typescript
35
+
```typescript twoslash
36
36
#!/usr/bin/envts-node
37
37
38
38
console.log("Hello, world!")
39
39
```
40
40
41
41
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))
42
42
43
-
```typescript
43
+
```typescript twoslash
44
44
#!/usr/bin/env-Sts-node--files
45
45
// This shebang works on Mac and Linux with newer versions of env
46
46
// Technically, Mac allows omitting `-S`, but Linux requires it
47
47
```
48
48
49
49
To write scripts with maximum portability, [specify all options in your `tsconfig.json`](./configuration#via-tsconfigjson-recommended) and omit them from the shebang.
0 commit comments