Skip to content

Commit e3f1df6

Browse files
committed
copy original files
1 parent f6280ba commit e3f1df6

9 files changed

+253
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
display: "disableReferencedProjectLoad"
3+
oneline: "Reduce the number of projects loaded automatically by TypeScript."
4+
---
5+
6+
In multi-project TypeScript programs, TypeScript will load all of the available projects into memory in order to provide accurate results for editor responses which require a full knowledge graph like 'Find All References'.
7+
8+
If your project is large, you can use the flag `disableReferencedProjectLoad` to disable the automatic loading of all projects. Instead, projects are loaded dynamically as you open files through your editor.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
display: "jsxFragmentFactory"
3+
oneline: "Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'."
4+
---
5+
6+
Specify the JSX fragment factory function to use when targeting react JSX emit with `jsxFactory` compiler option is specified, e.g. `Fragment`.
7+
8+
For example with this TSConfig:
9+
10+
```json tsconfig
11+
{
12+
"compilerOptions": {
13+
"target": "esnext",
14+
"module": "commonjs",
15+
"jsx": "react",
16+
"jsxFactory": "h",
17+
"jsxFragmentFactory": "Fragment"
18+
}
19+
}
20+
```
21+
22+
This TSX file:
23+
24+
```tsx
25+
import { h, Fragment } from "preact";
26+
27+
const HelloWorld = () => (
28+
<>
29+
<div>Hello</div>
30+
</>
31+
);
32+
```
33+
34+
Would look like:
35+
36+
```tsx twoslash
37+
// @showEmit
38+
// @showEmittedFile: index.js
39+
// @jsxFactory: h
40+
// @jsxFragmentFactory: Fragment
41+
// @noErrors
42+
// @target: esnext
43+
// @module: commonjs
44+
45+
import { h, Fragment } from "preact";
46+
47+
const HelloWorld = () => (
48+
<>
49+
<div>Hello</div>
50+
</>
51+
);
52+
```
53+
54+
This option can be used on a per-file basis too similar to [Babel's `/* @jsxFrag h */` directive](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#fragments).
55+
56+
For example:
57+
58+
```tsx twoslash
59+
/** @jsx h */
60+
/** @jsxFrag Fragment */
61+
62+
import { h, Fragment } from "preact";
63+
64+
const HelloWorld = () => (
65+
<>
66+
<div>Hello</div>
67+
</>
68+
);
69+
```
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
display: "jsxImportSource"
3+
oneline: "Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`"
4+
---
5+
6+
Declares the module specifier to be used for importing the `jsx` and `jsxs` factory functions when using [`jsx`](#jsx) as `"react-jsx"` or `"react-jsxdev"` which were introduced in TypeScript 4.1.
7+
8+
With [React 17](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) the library supports a new form of JSX transformation via a separate import.
9+
10+
For example with this code:
11+
12+
```tsx
13+
import React from "react";
14+
15+
function App() {
16+
return <h1>Hello World</h1>;
17+
}
18+
```
19+
20+
Using this TSConfig:
21+
22+
```json tsconfig
23+
{
24+
"compilerOptions": {
25+
"target": "esnext",
26+
"module": "commonjs",
27+
"jsx": "react-jsx"
28+
}
29+
}
30+
```
31+
32+
The emitted JavaScript from TypeScript is:
33+
34+
```tsx twoslash
35+
// @showEmit
36+
// @noErrors
37+
// @jsx: react-jsx
38+
// @module: commonjs
39+
// @target: esnext
40+
declare module JSX {
41+
interface Element {}
42+
interface IntrinsicElements {
43+
[s: string]: any;
44+
}
45+
}
46+
import React from "react";
47+
48+
function App() {
49+
return <h1>Hello World</h1>;
50+
}
51+
```
52+
53+
For example if you wanted to use `"jsxImportSource": "preact"`, you need a tsconfig like:
54+
55+
```json tsconfig
56+
{
57+
"compilerOptions": {
58+
"target": "esnext",
59+
"module": "commonjs",
60+
"jsx": "react-jsx",
61+
"jsxImportSource": "preact",
62+
"types": ["preact"]
63+
}
64+
}
65+
```
66+
67+
Which generates code like:
68+
69+
```tsx twoslash
70+
// @showEmit
71+
// @jsxImportSource: preact
72+
// @types: preact
73+
// @jsx: react-jsx
74+
// @target: esnext
75+
// @module: commonjs
76+
// @noErrors
77+
78+
export function App() {
79+
return <h1>Hello World</h1>;
80+
}
81+
```
82+
83+
Alternatively, you can use a per-file pragma to set this option, for example:
84+
85+
```tsx
86+
/** @jsxImportSource preact */
87+
88+
export function App() {
89+
return <h1>Hello World</h1>;
90+
}
91+
```
92+
93+
Would add `preact/jsx-runtime` as an import for the `_jsx` factory.
94+
95+
_Note:_ In order for this to work like you would expect, your `tsx` file must include an `export` or `import` so that it is considered a module.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
display: "noUncheckedIndexedAccess"
3+
oneline: "Add `undefined` to a type when accessed using an index."
4+
---
5+
6+
TypeScript has a way to describe objects which have unknown keys but known values on an object, via index signatures.
7+
8+
```ts twoslash
9+
interface EnvironmentVars {
10+
NAME: string;
11+
OS: string;
12+
13+
// Unknown properties are covered by this index signature.
14+
[propName: string]: string;
15+
}
16+
17+
declare const env: EnvironmentVars;
18+
19+
// Declared as existing
20+
const sysName = env.NAME;
21+
const os = env.OS;
22+
// ^?
23+
24+
// Not declared, but because of the index
25+
// signature, then it is considered a string
26+
const nodeEnv = env.NODE_ENV;
27+
// ^?
28+
```
29+
30+
Turning on `noUncheckedIndexedAccess` will add `undefined` to any un-declared field in the type.
31+
32+
```ts twoslash
33+
interface EnvironmentVars {
34+
NAME: string;
35+
OS: string;
36+
37+
// Unknown properties are covered by this index signature.
38+
[propName: string]: string;
39+
}
40+
// @noUncheckedIndexedAccess
41+
// ---cut---
42+
declare const env: EnvironmentVars;
43+
44+
// Declared as existing
45+
const sysName = env.NAME;
46+
const os = env.OS;
47+
// ^?
48+
49+
// Not declared, but because of the index
50+
// signature, then it is considered a string
51+
const nodeEnv = env.NODE_ENV;
52+
// ^?
53+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
display: "watchDirectory"
3+
oneline: "Specify how directories are watched on systems that lack recursive file-watching functionality."
4+
---
5+
6+
The strategy for how entire directory trees are watched under systems that lack recursive file-watching functionality.
7+
8+
- `fixedPollingInterval`: Check every directory for changes several times a second at a fixed interval.
9+
- `dynamicPriorityPolling`: Use a dynamic queue where less-frequently modified directories will be checked less often.
10+
- `useFsEvents` (the default): Attempt to use the operating system/file system's native events for directory changes.

docs/tsconfig/ja/options/watchFile.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
display: "watchFile"
3+
oneline: "Specify how the TypeScript watch mode works."
4+
---
5+
6+
The strategy for how individual files are watched.
7+
8+
- `fixedPollingInterval`: Check every file for changes several times a second at a fixed interval.
9+
- `priorityPollingInterval`: Check every file for changes several times a second, but use heuristics to check certain types of files less frequently than others.
10+
- `dynamicPriorityPolling`: Use a dynamic queue where less-frequently modified files will be checked less often.
11+
- `useFsEvents` (the default): Attempt to use the operating system/file system's native events for file changes.
12+
- `useFsEventsOnParentDirectory`: Attempt to use the operating system/file system's native events to listen for changes on a file's parent directory
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Compiler Options
2+
3+
These options make up the bulk of TypeScript's configuration and it covers how the language should work.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Root Fields
2+
3+
Starting up are the root options in the TSConfig - these options relate to how your TypeScript or JavaScript project is set up.

docs/tsconfig/ja/sections/watchOptions.md

Whitespace-only changes.

0 commit comments

Comments
 (0)