Skip to content

Commit 2966f34

Browse files
committed
Start of support for a full tsconfig reference including watch,. build and typesacquisition
1 parent 4727b4e commit 2966f34

29 files changed

+544
-160
lines changed

packages/documentation/copy/en/project-config/Compiler Options.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
148148
<td><code>boolean</code></td>
149149
</tr>
150150
<tr class="option-description even"><td colspan="3">
151-
<p>Delete the outputs of all projects</p>
151+
<p>Does something</p>
152152

153153
</tr></td>
154154
<tr class='odd' name='dry'>
@@ -160,15 +160,15 @@ tsc app.ts util.ts --target esnext --outfile index.js
160160

161161
</tr></td>
162162
<tr class='even' name='force'>
163-
<td><code>--force</code></td>
163+
<td><code><a href='/tsconfig/#force'>--force</a></code></td>
164164
<td><code>boolean</code></td>
165165
</tr>
166166
<tr class="option-description even"><td colspan="3">
167167
<p>Build all projects, including those that appear to be up to date</p>
168168

169169
</tr></td>
170170
<tr class='odd' name='verbose'>
171-
<td><code>--verbose</code></td>
171+
<td><code><a href='/tsconfig/#verbose'>--verbose</a></code></td>
172172
<td><code>boolean</code></td>
173173
</tr>
174174
<tr class="option-description odd"><td colspan="3">
@@ -193,15 +193,15 @@ tsc app.ts util.ts --target esnext --outfile index.js
193193
<td><code>list</code></td>
194194
</tr>
195195
<tr class="option-description odd"><td colspan="3">
196-
<p>Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively.</p>
196+
<p>Synchronously call callbacks and update the state of directory watchers on platforms that do not support recursive watching natively.</p>
197197

198198
</tr></td>
199199
<tr class='even' name='excludeFiles'>
200200
<td><code><a href='/tsconfig/#excludeFiles'>--excludeFiles</a></code></td>
201201
<td><code>list</code></td>
202202
</tr>
203203
<tr class="option-description even"><td colspan="3">
204-
<p>Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively.</p>
204+
<p>Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.</p>
205205

206206
</tr></td>
207207
<tr class='odd' name='fallbackPolling'>
@@ -217,7 +217,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
217217
<td><code>boolean</code></td>
218218
</tr>
219219
<tr class="option-description even"><td colspan="3">
220-
<p>Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively.</p>
220+
<p>Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.</p>
221221

222222
</tr></td>
223223
<tr class='odd' name='watch'>
@@ -709,7 +709,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
709709
</tr></td>
710710
<tr class='even' name='module'>
711711
<td><code><a href='/tsconfig/#module'>--module</a></code></td>
712-
<td><code><code>`CommonJS` (default if `target` is `ES3` or `ES5`)</code>, <code></code>, <code>`ES6`/`ES2015` (synonymous, default for `target` `ES6` and higher)</code>, <code></code>, <code>`ES2020`</code>, <code>`None`</code>, <code>`UMD`</code>, <code>`AMD`</code>, <code>`System`</code>, or <code>`ESNext`</code></code></td>
712+
<td><code><code>`CommonJS` (default if `target` is `ES3` or `ES5`)</code>, <code></code>, <code>`ES2015`</code>, <code>`ES2020`</code>, <code></code>, <code>`None`</code>, <code>`UMD`</code>, <code>`AMD`</code>, <code>`System`</code>, or <code>`ESNext`</code></code></td>
713713
<td>
714714
</td>
715715
</tr>

packages/playground/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export const setupPlayground = (
172172
return
173173
}
174174
const newURL = sandbox.createURLQueryWithCompilerOptions(sandbox)
175+
debugger
175176
window.history.replaceState({}, "", newURL)
176177
}
177178
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "clean"
3+
oneline: "Does something"
4+
---
5+
Delete the outputs of all projects
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "disableFilenameBasedTypeAcquisition"
3+
oneline: "Does something"
4+
---
5+
undefined
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "enable"
3+
oneline: "Does something"
4+
---
5+
undefined
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "enableAutoDiscovery"
3+
oneline: "Does something"
4+
---
5+
undefined
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "excludeDirectories"
3+
oneline: "Synchronously call callbacks and update the state of directory watchers on platforms that do not support recursive watching natively."
4+
---
5+
6+
Synchronously call callbacks and update the state of directory watchers on platforms that do not support recursive watching natively.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
display: "excludeFiles"
3+
oneline: "Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively."
4+
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "force"
3+
oneline: "Build all projects, including those that appear to be up to date"
4+
---
5+
6+
Build all projects, including those that appear to be up to date

packages/tsconfig-reference/copy/en/options/module.md

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ import { valueOfPi } from "./constants";
8585
export const twoPi = valueOfPi * 2;
8686
```
8787

88+
If you are wondering about the difference between ES2015 and ES2020, ES2020 adds support for dynamic `import`s, and `import.meta`.
89+
8890
### `None`
8991

9092
```ts twoslash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "synchronousWatchDirectory"
3+
oneline: "Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively."
4+
---
5+
6+
Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "Exclude"
3+
oneline: "Specify a list of modules which to exclude."
4+
---
5+
6+
123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "Include"
3+
oneline: "Specify a list of modules which to include."
4+
---
5+
6+
123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
display: "verbose"
3+
oneline: "Enable verbose logging"
4+
---
5+
6+
Enable verbose logging
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Build Options
2+
3+
Type Acquisition is only important for JavaScript projects. In TypeScript projects you need to include the types in your projects explicitly. However, for JavaScript projects, the TypeScript tooling will download types for your modules in the background and outside of your node_modules folder.
4+
5+
You may not want this, in which case you can turn off type acquisition by having this `jsconfig.json` in the root of your project:
6+
7+
```json
8+
{
9+
"typeAcquisition": {
10+
"enable": false
11+
}
12+
}
13+
```
14+
15+
Common uses for this section of a `jsconfig.json` is to tell TypeScript to download additional definitions for your tooling experience:
16+
17+
```json
18+
{
19+
"typeAcquisition": {
20+
"include": ["jquery"]
21+
}
22+
}
23+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Type Acquisition
2+
3+
Type Acquisition is only important for JavaScript projects. In TypeScript projects you need to include the types in your projects explicitly. However, for JavaScript projects, the TypeScript tooling will download types for your modules in the background and outside of your node_modules folder.
4+
5+
You may not want this, in which case you can turn off type acquisition by having this `jsconfig.json` in the root of your project:
6+
7+
```json
8+
{
9+
"typeAcquisition": {
10+
"enable": false
11+
}
12+
}
13+
```
14+
15+
Common uses for this section of a `jsconfig.json` is to tell TypeScript to download additional definitions for your tooling experience:
16+
17+
```json
18+
{
19+
"typeAcquisition": {
20+
"include": ["jquery"]
21+
}
22+
}
23+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Watch Options
2+
3+
There are a series of watch options which live in
4+
5+
```json
6+
{
7+
"watchOptions": {
8+
"watchFile": "fixedPollingInterval"
9+
}
10+
}
11+
```

packages/tsconfig-reference/data/_types.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,19 @@ export type CompilerOptionName =
109109
| "noStrictGenericChecks"
110110
| "useDefineForClassFields"
111111
| "keyofStringsOnly"
112-
| "plugins";
112+
| "plugins"
113+
| "watchFile"
114+
| "watchDirectory"
115+
| "fallbackPolling"
116+
| "synchronousWatchDirectory"
117+
| "excludeDirectories"
118+
| "excludeFiles"
119+
| "verbose"
120+
| "dry"
121+
| "force"
122+
| "clean"
123+
| "enableAutoDiscovery"
124+
| "enable"
125+
| "include"
126+
| "exclude"
127+
| "disableFilenameBasedTypeAcquisition";

packages/tsconfig-reference/scripts/cli/generateJSON.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
node --inspect-brk ./node_modules/.bin/ts-node packages/tsconfig-reference/scripts/cli/generateJSON.ts
66
yarn ts-node scripts/cli/generateJSON.ts
77
*/
8+
console.log("TSConfig Ref: JSON for CLI Opts");
89

910
import * as ts from "typescript";
1011

packages/tsconfig-reference/scripts/cli/generateMarkdown.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
node --inspect-brk ./node_modules/.bin/ts-node --project packages/tsconfig-reference/tsconfig.json packages/tsconfig-reference/scripts/generateMarkdown.ts
66
yarn ts-node --project packages/tsconfig-reference/tsconfig.json packages/tsconfig-reference/scripts/generateMarkdown.ts
77
*/
8+
console.log("TSConfig Ref: MD for CLI Opts");
89

910
import { writeFileSync, readdirSync, existsSync, readFileSync } from "fs";
1011
import { join } from "path";

packages/tsconfig-reference/scripts/msbuild/generateJSON.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// yarn workspace tsconfig-reference generate:msbuild:schema
22

3+
console.log("TSConfig Ref: JSON for MSBuild");
4+
35
import parser = require("xml-js");
46
import { readFileSync, writeFileSync } from "fs";
57
import { join } from "path";

packages/tsconfig-reference/scripts/msbuild/generateMarkdown.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
yarn ts-node --project packages/tsconfig-reference/tsconfig.json packages/tsconfig-reference/scripts/msbuild/generateMarkdown.ts
77
*/
88

9+
console.log("TSConfig Ref: MD for MSBuild");
10+
911
import { writeFileSync, readdirSync, existsSync, readFileSync } from "fs";
1012
import { join } from "path";
1113
import { read as readMarkdownFile } from "gray-matter";

packages/tsconfig-reference/scripts/schema/generateJSON.ts

+28-12
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
yarn ts-node scripts/cli/generateJSON.ts
77
yarn workspace tsconfig-reference generate:json:schema
88
*/
9-
console.log("Generating JSON schema");
9+
console.log("TSConfig Ref: JSON schema");
1010

11-
import * as ts from "typescript";
1211
import { read as readMarkdownFile } from "gray-matter";
1312
import { CommandLineOptionBase } from "../types";
1413
import { writeFileSync } from "fs";
1514
import { join } from "path";
1615
import { format } from "prettier";
17-
import { deprecated } from "../tsconfigRules";
1816
import { CompilerOptionName } from "../../data/_types";
1917

2018
const toJSONString = (obj) => format(JSON.stringify(obj, null, " "), { filepath: "thing.json" });
@@ -43,6 +41,10 @@ const filteredOptions = tsconfigOpts
4341

4442
const schemaCompilerOpts =
4543
schemaBase.definitions.compilerOptionsDefinition.properties.compilerOptions.properties;
44+
const schemaWatchOpts =
45+
schemaBase.definitions.watchOptionsDefinition.properties.watchOptions.properties;
46+
const schemaBuildOpts =
47+
schemaBase.definitions.buildOptionsDefinition.properties.buildOptions.properties;
4648

4749
const okToSkip = [
4850
"exclude",
@@ -57,14 +59,19 @@ const okToSkip = [
5759

5860
filteredOptions.forEach((option) => {
5961
const name = option.name as CompilerOptionName;
62+
if (okToSkip.includes(name)) return;
6063
const sectionsPath = join(__dirname, `../../copy/en/options/${name}.md`);
6164

62-
if (!schemaCompilerOpts[name]) {
63-
if (okToSkip.includes(name)) return;
65+
let section;
66+
if (schemaCompilerOpts[name]) section = schemaCompilerOpts;
67+
if (schemaWatchOpts[name]) section = schemaWatchOpts;
68+
if (schemaBuildOpts[name]) section = schemaBuildOpts;
69+
70+
if (!section) {
6471
const title = `Issue creating JSON Schema for tsconfig`;
65-
const headline = `Could not find '${name}' in schemaBase.definitions.compilerOptionsDefinition.properties.compilerOptions.properties`;
72+
const headline = `Could not find '${name}' in schemaBase.definitions - it needs to either be in compilerOptions / watchOptions / buildOptions`;
6673
const msg = `You need to add it to the file: packages/tsconfig-reference/scripts/schema/vendor/base.json - something like:
67-
74+
6875
"${name}": {
6976
"description": "${option.description.message}",
7077
"type": "boolean",
@@ -73,18 +80,27 @@ filteredOptions.forEach((option) => {
7380
7481
You're also going to need to make the new Markdown file for the compiler flag, run:
7582
76-
\n echo '---\\ndisplay: "${option.name}"\\noneline: "Does something"\\n---\\n${option.description.message}\\n' > ${sectionsPath}\n\nThen add some docs and run: \n> yarn workspace tsconfig-reference build\n\n
83+
\n echo '---\\ndisplay: "${option.name}"\\noneline: "Does something"\\n---\\n${option.description.message}\\n ' > ${sectionsPath}\n\nThen add some docs and run: \n> yarn workspace tsconfig-reference build\n\n
7784
`;
7885

7986
throw new Error([title, headline, msg, ""].join("\n\n"));
8087
} else {
81-
const optionFile = readMarkdownFile(sectionsPath);
88+
let optionFile;
89+
90+
try {
91+
optionFile = readMarkdownFile(sectionsPath);
92+
} catch (error) {
93+
// prettier-ignore
94+
throw new Error(
95+
`\n echo '---\\ndisplay: "${option.name}"\\noneline: "Does something" \\n---\\n${option.description.message.replace("'", "`")}\\n ' > ${sectionsPath}\n\nThen add some docs and run: \n> yarn workspace tsconfig-reference build\n\n`
96+
);
97+
}
8298

8399
// Set the plain version
84-
schemaCompilerOpts[name].description = optionFile.data.oneline;
100+
section[name].description = optionFile.data.oneline;
85101

86102
// Can be removed once https://github.com/ExodusMovement/schemasafe/pull/146 is merged
87-
const isEnumOrConst = schemaCompilerOpts[name]["enum"];
103+
const isEnumOrConst = section[name]["enum"];
88104
if (isEnumOrConst) return;
89105

90106
// See the vscode extensions here:
@@ -95,7 +111,7 @@ You're also going to need to make the new Markdown file for the compiler flag, r
95111

96112
// Set a markdown version which is prioritised in vscode, giving people
97113
// the chance to click on the links.
98-
schemaCompilerOpts[name].markdownDescription =
114+
section[name].markdownDescription =
99115
optionFile.data.oneline + `\n\nSee more: https://www.typescriptlang.org/tsconfig#${name}`;
100116
}
101117
});

0 commit comments

Comments
 (0)