Skip to content

Commit dd698b2

Browse files
ortaAndarist
andauthored
Updates the site for 4.6 (microsoft#2288)
* Removes the .js files from the tsconfig reference * Wrapup for 4.6 * Adjust twoslash inlay provider to use the new Monaco API for that * Manual monaco keycode change - fixes microsoft#2267 * Better markdown fix * Type update for another monaco keycode * Drops the node12 example from module because it doesn't work on prod * Note the twoslash cache * Add tests Co-authored-by: Mateusz Burzyński <[email protected]>
1 parent a8e2fb3 commit dd698b2

File tree

29 files changed

+125
-1329
lines changed

29 files changed

+125
-1329
lines changed

docs/New TypeScript Version.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ That will update all of the site to use 3.9.0 for building. Run `yarn build` to
2020

2121
You might see issues with yarn patching TypeScript, if so, try run: `yarn set version latest` first to update to the latest yarn.
2222

23+
Then empty the twoslash cache: `rm node_modules/.cache/twoslash`.
24+
2325
##### New Handbook Docs
2426

2527
You might have a new reference doc to add, they live in [`packages/documentation/copy`](https://github.com/microsoft/TypeScript-website/blob/v2/packages/documentation/copy). You can ignore languages other than `en`. The folder structure is only for your reference and has no bearing on the site navigation. Each markdown document needs a header like:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@types/react": "16.9.17",
2424
"@types/estree": "0.0.46",
2525
"node-gyp": "5.1.0",
26-
"typescript": "4.5.0-beta",
26+
"typescript": "4.6.2",
2727
"tslib": "2.1.0",
2828
"prettier": "^2.0.2",
2929
"shelljs": "0.8.4",

packages/create-typescript-playground-plugin/template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@rollup/plugin-typescript": "^3.0.0",
2727
"@types/react": "^16.9.23",
2828
"concurrently": "^5.1.0",
29-
"monaco-editor": "^0.29.1",
29+
"monaco-editor": "^0.32.1",
3030
"node-fetch": "^2.6.0",
3131
"rollup": "^1.31.0",
3232
"serve": "^11.3.0",

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
305305
<td><code><a href='/tsconfig/#allowUnreachableCode'>--allowUnreachableCode</a></code></td>
306306
<td><p><code>boolean</code></p>
307307
</td>
308-
<td><p><code>undefined</code></p>
308+
<td>
309309
</td>
310310
</tr>
311311
<tr class="option-description even"><td colspan="3">
@@ -316,7 +316,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
316316
<td><code><a href='/tsconfig/#allowUnusedLabels'>--allowUnusedLabels</a></code></td>
317317
<td><p><code>boolean</code></p>
318318
</td>
319-
<td><p><code>undefined</code></p>
319+
<td>
320320
</td>
321321
</tr>
322322
<tr class="option-description odd"><td colspan="3">
@@ -339,7 +339,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
339339
<td><code><a href='/tsconfig/#assumeChangesOnlyAffectDirectDependencies'>--assumeChangesOnlyAffectDirectDependencies</a></code></td>
340340
<td><p><code>boolean</code></p>
341341
</td>
342-
<td>
342+
<td><p><code>false</code></p>
343343
</td>
344344
</tr>
345345
<tr class="option-description odd"><td colspan="3">
@@ -406,7 +406,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
406406
<td><code><a href='/tsconfig/#declarationDir'>--declarationDir</a></code></td>
407407
<td><p><code>string</code></p>
408408
</td>
409-
<td><p>n/a</p>
409+
<td>
410410
</td>
411411
</tr>
412412
<tr class="option-description odd"><td colspan="3">
@@ -439,7 +439,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
439439
<td><code><a href='/tsconfig/#disableReferencedProjectLoad'>--disableReferencedProjectLoad</a></code></td>
440440
<td><p><code>boolean</code></p>
441441
</td>
442-
<td>
442+
<td><p><code>false</code></p>
443443
</td>
444444
</tr>
445445
<tr class="option-description even"><td colspan="3">
@@ -461,7 +461,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
461461
<td><code><a href='/tsconfig/#disableSolutionSearching'>--disableSolutionSearching</a></code></td>
462462
<td><p><code>boolean</code></p>
463463
</td>
464-
<td>
464+
<td><p><code>false</code></p>
465465
</td>
466466
</tr>
467467
<tr class="option-description even"><td colspan="3">
@@ -472,7 +472,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
472472
<td><code><a href='/tsconfig/#disableSourceOfProjectReferenceRedirect'>--disableSourceOfProjectReferenceRedirect</a></code></td>
473473
<td><p><code>boolean</code></p>
474474
</td>
475-
<td>
475+
<td><p><code>false</code></p>
476476
</td>
477477
</tr>
478478
<tr class="option-description odd"><td colspan="3">
@@ -516,7 +516,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
516516
<td><code><a href='/tsconfig/#emitDecoratorMetadata'>--emitDecoratorMetadata</a></code></td>
517517
<td><p><code>boolean</code></p>
518518
</td>
519-
<td>
519+
<td><p><code>false</code></p>
520520
</td>
521521
</tr>
522522
<tr class="option-description odd"><td colspan="3">
@@ -538,18 +538,18 @@ tsc app.ts util.ts --target esnext --outfile index.js
538538
<td><code><a href='/tsconfig/#exactOptionalPropertyTypes'>--exactOptionalPropertyTypes</a></code></td>
539539
<td><p><code>boolean</code></p>
540540
</td>
541-
<td>
541+
<td><p><code>false</code></p>
542542
</td>
543543
</tr>
544544
<tr class="option-description odd"><td colspan="3">
545-
<p>Differentiate between undefined and not present when type checking.</p>
545+
<p>Interpret optional property types as written, rather than adding <code>undefined</code>.</p>
546546
</td></tr>
547547

548548
<tr class='even' name='experimentalDecorators'>
549549
<td><code><a href='/tsconfig/#experimentalDecorators'>--experimentalDecorators</a></code></td>
550550
<td><p><code>boolean</code></p>
551551
</td>
552-
<td>
552+
<td><p><code>false</code></p>
553553
</td>
554554
</tr>
555555
<tr class="option-description even"><td colspan="3">
@@ -560,7 +560,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
560560
<td><code><a href='/tsconfig/#explainFiles'>--explainFiles</a></code></td>
561561
<td><p><code>boolean</code></p>
562562
</td>
563-
<td>
563+
<td><p><code>false</code></p>
564564
</td>
565565
</tr>
566566
<tr class="option-description odd"><td colspan="3">
@@ -615,7 +615,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
615615
<td><code><a href='/tsconfig/#importsNotUsedAsValues'>--importsNotUsedAsValues</a></code></td>
616616
<td><p><code>remove</code>, <code>preserve</code>, or <code>error</code></p>
617617
</td>
618-
<td>
618+
<td><p><code>remove</code></p>
619619
</td>
620620
</tr>
621621
<tr class="option-description even"><td colspan="3">
@@ -791,7 +791,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
791791

792792
<tr class='even' name='moduleResolution'>
793793
<td><code><a href='/tsconfig/#moduleResolution'>--moduleResolution</a></code></td>
794-
<td><p><code>classic</code> or <code>node</code></p>
794+
<td><p><code>classic</code>, <code>node</code>, <code>node12</code>, or <code>nodenext</code></p>
795795
</td>
796796
<td><ul><li><p><code>Classic</code> if <a href="#module"><code>module</code></a> is <code>AMD</code>, <code>UMD</code>, <code>System</code> or <code>ES6</code>/<code>ES2015</code>,</p>
797797
</li><li><p>Matches if <a href="#module"><code>module</code></a> is <code>node12</code> or <code>nodenext</code>,</p>
@@ -861,7 +861,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
861861
<td><code><a href='/tsconfig/#noFallthroughCasesInSwitch'>--noFallthroughCasesInSwitch</a></code></td>
862862
<td><p><code>boolean</code></p>
863863
</td>
864-
<td>
864+
<td><p><code>false</code></p>
865865
</td>
866866
</tr>
867867
<tr class="option-description even"><td colspan="3">
@@ -877,14 +877,14 @@ tsc app.ts util.ts --target esnext --outfile index.js
877877
</li></ul></td>
878878
</tr>
879879
<tr class="option-description odd"><td colspan="3">
880-
<p>Enable error reporting for expressions and declarations with an implied <code>any</code> type..</p>
880+
<p>Enable error reporting for expressions and declarations with an implied <code>any</code> type.</p>
881881
</td></tr>
882882

883883
<tr class='even' name='noImplicitOverride'>
884884
<td><code><a href='/tsconfig/#noImplicitOverride'>--noImplicitOverride</a></code></td>
885885
<td><p><code>boolean</code></p>
886886
</td>
887-
<td>
887+
<td><p><code>false</code></p>
888888
</td>
889889
</tr>
890890
<tr class="option-description even"><td colspan="3">
@@ -973,7 +973,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
973973
<td><code><a href='/tsconfig/#noUncheckedIndexedAccess'>--noUncheckedIndexedAccess</a></code></td>
974974
<td><p><code>boolean</code></p>
975975
</td>
976-
<td>
976+
<td><p><code>false</code></p>
977977
</td>
978978
</tr>
979979
<tr class="option-description even"><td colspan="3">
@@ -1006,7 +1006,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
10061006
<td><code><a href='/tsconfig/#out'>--out</a></code></td>
10071007
<td><p><code>string</code></p>
10081008
</td>
1009-
<td><p>n/a</p>
1009+
<td>
10101010
</td>
10111011
</tr>
10121012
<tr class="option-description odd"><td colspan="3">
@@ -1017,7 +1017,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
10171017
<td><code><a href='/tsconfig/#outDir'>--outDir</a></code></td>
10181018
<td><p><code>string</code></p>
10191019
</td>
1020-
<td><p>n/a</p>
1020+
<td>
10211021
</td>
10221022
</tr>
10231023
<tr class="option-description even"><td colspan="3">
@@ -1028,7 +1028,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
10281028
<td><code><a href='/tsconfig/#outFile'>--outFile</a></code></td>
10291029
<td><p><code>string</code></p>
10301030
</td>
1031-
<td><p>n/a</p>
1031+
<td>
10321032
</td>
10331033
</tr>
10341034
<tr class="option-description odd"><td colspan="3">
@@ -1073,7 +1073,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
10731073
<td><code><a href='/tsconfig/#preserveSymlinks'>--preserveSymlinks</a></code></td>
10741074
<td><p><code>boolean</code></p>
10751075
</td>
1076-
<td><p>n/a</p>
1076+
<td><p><code>false</code></p>
10771077
</td>
10781078
</tr>
10791079
<tr class="option-description odd"><td colspan="3">
@@ -1084,7 +1084,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
10841084
<td><code><a href='/tsconfig/#preserveValueImports'>--preserveValueImports</a></code></td>
10851085
<td><p><code>boolean</code></p>
10861086
</td>
1087-
<td>
1087+
<td><p><code>false</code></p>
10881088
</td>
10891089
</tr>
10901090
<tr class="option-description even"><td colspan="3">
@@ -1095,7 +1095,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
10951095
<td><code><a href='/tsconfig/#preserveWatchOutput'>--preserveWatchOutput</a></code></td>
10961096
<td><p><code>boolean</code></p>
10971097
</td>
1098-
<td><p>n/a</p>
1098+
<td><p><code>false</code></p>
10991099
</td>
11001100
</tr>
11011101
<tr class="option-description odd"><td colspan="3">
@@ -1275,7 +1275,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
12751275
<td><code><a href='/tsconfig/#stripInternal'>--stripInternal</a></code></td>
12761276
<td><p><code>boolean</code></p>
12771277
</td>
1278-
<td>
1278+
<td><p><code>false</code></p>
12791279
</td>
12801280
</tr>
12811281
<tr class="option-description odd"><td colspan="3">
@@ -1306,7 +1306,7 @@ tsc app.ts util.ts --target esnext --outfile index.js
13061306

13071307
<tr class='even' name='target'>
13081308
<td><code><a href='/tsconfig/#target'>--target</a></code></td>
1309-
<td><p><code>es3</code>, <code>es5</code>, <code>es6</code>/<code>es2015</code>, <code>es2016</code>, <code>es2017</code>, <code>es2018</code>, <code>es2019</code>, <code>es2020</code>, <code>es2021</code>, or <code>esnext</code></p>
1309+
<td><p><code>es3</code>, <code>es5</code>, <code>es6</code>/<code>es2015</code>, <code>es2016</code>, <code>es2017</code>, <code>es2018</code>, <code>es2019</code>, <code>es2020</code>, <code>es2021</code>, <code>es2022</code>, or <code>esnext</code></p>
13101310
</td>
13111311
<td><p><code>ES3</code></p>
13121312
</td>

packages/documentation/copy/en/reference/Advanced Types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ Note that this syntax describes a type rather than a member.
756756
If you want to add members, you can use an intersection type:
757757

758758
```ts twoslash
759-
// @errors: 2693 1005 1128
759+
// @errors: 2693 1005 1128 7061
760760
// Use this:
761761
type PartialWithNewMember<T> = {
762762
[P in keyof T]?: T[P];

packages/playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"devDependencies": {
2323
"@types/jest": "^25.1.3",
2424
"jest": "*",
25-
"monaco-editor": "^0.29.1",
25+
"monaco-editor": "^0.32.1",
2626
"monaco-typescript": "^3.7.0",
2727
"typescript": "*"
2828
}

packages/playground/src/index.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,25 @@ export const setupPlayground = (
188188
// something more inline, but we can abuse the code lenses for now because they get their own line!
189189
sandbox.monaco.languages.registerCodeLensProvider(sandbox.language, {
190190
provideCodeLenses: function (model, token) {
191-
const lenses = !showFileCodeLens ? [] : [{
192-
range: {
193-
startLineNumber: 1,
194-
startColumn: 1,
195-
endLineNumber: 2,
196-
endColumn: 1
197-
},
198-
id: "implicit-filename-first",
199-
command: {
200-
id: "noop",
201-
title: `// @filename: ${sandbox.filepath}`
202-
}
203-
}]
204-
return { lenses, dispose: () => { } };
205-
}
191+
const lenses = !showFileCodeLens
192+
? []
193+
: [
194+
{
195+
range: {
196+
startLineNumber: 1,
197+
startColumn: 1,
198+
endLineNumber: 2,
199+
endColumn: 1,
200+
},
201+
id: "implicit-filename-first",
202+
command: {
203+
id: "noop",
204+
title: `// @filename: ${sandbox.filepath}`,
205+
},
206+
},
207+
]
208+
return { lenses, dispose: () => {} }
209+
},
206210
})
207211

208212
let showFileCodeLens = false
@@ -394,7 +398,7 @@ export const setupPlayground = (
394398
const shareAction = {
395399
id: "copy-clipboard",
396400
label: "Save to clipboard",
397-
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S],
401+
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS],
398402

399403
contextMenuGroupId: "run",
400404
contextMenuOrder: 1.5,
@@ -714,7 +718,11 @@ export const setupPlayground = (
714718
}
715719
}
716720

717-
if (monaco.languages.registerInlayHintsProvider) {
721+
const [tsMajor, tsMinor] = sandbox.ts.version.split(".")
722+
if (
723+
(parseInt(tsMajor) > 4 || (parseInt(tsMajor) == 4 && parseInt(tsMinor) >= 6)) &&
724+
monaco.languages.registerInlayHintsProvider
725+
) {
718726
monaco.languages.registerInlayHintsProvider(sandbox.language, createTwoslashInlayProvider(sandbox))
719727
}
720728

packages/playground/src/sidebar/runtime.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const runPlugin: PluginFactory = (i, utils) => {
2222
const clearLogsAction = {
2323
id: "clear-logs-play",
2424
label: "Clear Playground Logs",
25-
keybindings: [sandbox.monaco.KeyMod.CtrlCmd | sandbox.monaco.KeyCode.KEY_K],
25+
keybindings: [sandbox.monaco.KeyMod.CtrlCmd | sandbox.monaco.KeyCode.KeyK],
2626

2727
contextMenuGroupId: "run",
2828
contextMenuOrder: 1.5,
@@ -183,7 +183,7 @@ function rewireLoggingToElement(
183183
const replacers = {
184184
"<span class='literal'>null</span>": "1231232131231231423434534534",
185185
"<span class='literal'>undefined</span>": "4534534534563567567567",
186-
"<span class='comma'>, </span>": "785y8345873485763874568734y535438"
186+
"<span class='comma'>, </span>": "785y8345873485763874568734y535438",
187187
}
188188

189189
const objectToText = (arg: any): string => {
@@ -207,7 +207,9 @@ function rewireLoggingToElement(
207207
const mapIter = [...arg.entries()]
208208
textRep =
209209
`Map (${arg.size}) {` +
210-
mapIter.map(([k, v]) => `${objectToText(k)} => ${objectToText(v)}`).join(replacers["<span class='comma'>, </span>"]) +
210+
mapIter
211+
.map(([k, v]) => `${objectToText(k)} => ${objectToText(v)}`)
212+
.join(replacers["<span class='comma'>, </span>"]) +
211213
"}"
212214
} else if (typeof arg === "string") {
213215
textRep = '"' + htmlEscape(arg) + '"'
@@ -254,5 +256,5 @@ function sanitizeJS(code: string) {
254256
}
255257

256258
function htmlEscape(str: string) {
257-
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
258-
}
259+
return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;")
260+
}

0 commit comments

Comments
 (0)