Skip to content

Commit 89ff34f

Browse files
author
Orta
authored
Merge pull request #242 from microsoft/learn
Update the wiki to use the right links and offer some better advice about how to debug the wiki
2 parents 61446a8 + 6e95591 commit 89ff34f

28 files changed

+36
-30
lines changed

.github/workflows/sync.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# Update search links from the origin repo before pushing to the upstream
2323
- run: git clone --depth 1 https://github.com/microsoft/TypeScript.git
2424
- run: npm i
25-
- run: node scripts/convertRelativeLinksToHardcoded.js **/*.md --write
25+
- run: node scripts/convertRelativeLinksToHardcoded.js "**/*.md" --write
2626
- run: rm -rf TypeScript
2727

2828
- run: git add .

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ Then you can open: `http://localhost:4567`
2020

2121
Things to remember:
2222

23+
- Gollum is a bit of a nightmare for testing, my current technique is:
24+
25+
```sh
26+
# before
27+
git branch -b thing_i_am_working_on
28+
29+
# to iterate, amend the commit and re-run gollum against that bit of git
30+
git add .; git commit --amend --no-edit --no-verify; gollum --ref thing_i_am_working_on
31+
```
32+
2333
- Wikis don't support nesting, so filenames have to get a bit wild
2434

2535
```diff
Binary file not shown.

compiler/codebase/src/services/formatting.md

-1
This file was deleted.
-1.44 MB
Binary file not shown.

compiler/systems/testing/units.md

Whitespace-only changes.
File renamed without changes.

compiler/codebase/src/compiler/checker-inferrence.md renamed to learn/compiler/compiler-checker-inferrence.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ This function takes a few params:
1717
const a = "Hello World";
1818
```
1919

20-
<!-- prettier-ignore-start -->
20+
<!-- prettier-ignore-start -->
2121

2222
[0]: <src/compiler/checker.ts - function inferTypes(>
2323
[1]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-6.html#strict-function-types
2424

25-
<!-- prettier-ignore-end -->
25+
<!-- prettier-ignore-end -->

compiler/CONTRIBUTING.md renamed to learn/getting-started-with-the-compiler.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This page follows on from [README.md](./README.md).
1+
This page follows on from [[Learn the Compiler|learn-the-compiler]].
22

33
### Getting set up
44

@@ -30,8 +30,10 @@ You'll probably want to add the following to your watch section in VS Code:
3030
This is really useful for keeping track of changing state, and it's pretty often that those are the names of
3131
things you're looking for.
3232

33+
If you want to see what a debugging session looks like with the compiler team, watch [these](https://www.youtube.com/watch?v=3vwO4DwlGYE) [videos](https://www.youtube.com/watch?v=Xq4p5LXaO8Y).
34+
3335
### Getting started
3436

35-
You can learn about the different ways to [write a test here](./systems/testing) to try and re-produce a bug. It
37+
You can learn about the different ways to [[write a test here|systems-testing]] to try and re-produce a bug. It
3638
might be a good idea to look in the recently closed PRs to find something small which adds a test case, then read
3739
the test and the code changes to get used to the flow.

compiler/README.md renamed to learn/learn-the-compiler.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ code .
2121
gulp runtests-parallel
2222
```
2323

24-
To dive deeper into getting set up to work on the codebase, read [the CONTRIBUTING.md](./CONTRIBUTING.md).
24+
25+
To dive deeper into getting set up to work on the codebase, read: [[Getting Set Up|getting-started-with-the-compiler]].
2526

2627
### Critical prior knowledge
2728

compiler/systems/testing/baselines.md renamed to learn/systems/systems-baselines.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Baselines
22

3-
Baseline tests are effectively large folder-based snapshot tests. Like [fourslash](./fourslash), these tests are
3+
Baseline tests are effectively large folder-based snapshot tests. Like [[Baselines|systems-fourslash]], these tests are
44
somewhat integration level. These test generally test the internals of the compiler, they do this by you creating
55
a TypeScript file where the snapshot result is a symbol map of all the symbols in that file and a list of all
66
raised errors then compiling the tests.
77

88
### How to make a baseline
99

10-
1. Make a new file: ` touch tests/cases/compiler/overloadFunctionsNotEqualToGenerics.ts`. Add some TypeScript to it.
11-
2. d
10+
1. Make a new file: ` touch tests/cases/compiler/overloadFunctionsNotEqualToGenerics.ts`.
11+
1. Add some TypeScript to it.
12+
1. Run run your test in
1213

1314

1415
### How to amend a baseline
@@ -29,13 +30,8 @@ tests/baselines/local/
2930
```
3031

3132
This lets you know that two tests have changed from what you expect. They live in `local/api`, so you can compare
32-
the folders. I normally use [Kaleidoscope](https://www.kaleidoscopeapp.com), but the team loves
33-
[Beyond Compare](https://scootersoftware.com) - it's a bit Windows-y but does a good job showing you how the
33+
the folders. The team loves [Beyond Compare](https://scootersoftware.com) - it does a good job showing you how the
3434
folder infrastructure differs.
3535

36-
![./screenshots/diff.png](./screenshots/diff.png)
37-
38-
39-
4036
Once you're happy with the new baselines, you can run `gulp baseline-accept` to move them into the codebase.
4137
You will be able to see your diffs in git now. :+1:

compiler/systems/cli.md renamed to learn/systems/systems-cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const errors: Diagnostic[] = [];
1717
Then it starts If the letter is a - then start looking forwards to see if the arg is available in [the
1818
optionmap][4]
1919

20-
[0]: src/tsc/tsc.ts
20+
[0]: https://github.com/microsoft/TypeScript/blob/master/src/tsc/tsc.ts
2121
[1]: <src/tsc/tsc.ts - function executeCommandLine>
2222
[2]: <src/compiler/types.ts - export interface ParsedCommandLine>
2323
[3]: <src/compiler/commandLineParser.ts - function parseCommandLineWorker>
File renamed without changes.

compiler/systems/formatting/formatting.md renamed to learn/systems/systems-formatting.md

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ requests a set of rules which can be applied to the items via `createRulesMap`.
3232
There are a lot of rules, which you can find in [rules.ts](./rules.ts) each one has a left and right reference to
3333
nodes or token ranges and note of what action should be applied by the formatter.
3434

35-
## Rules
36-
3735
### Where is this used?
3836

3937
The formatter is used mainly from any language service operation that inserts or modifies code. The formatter is

compiler/systems/testing/fourslash.md renamed to learn/systems/systems-fourslash.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ moment;`
5353
### Formatting
5454

5555
<!-- prettier-ignore-start -->
56-
[0]: /src/testRunner/fourslashRunner.ts
57-
[1]: /tests/cases/fourslash
58-
[2]: /src/testRunner/runner.ts
59-
[3]: /src/harness/fourslash.ts
56+
[0]: https://github.com/microsoft/TypeScript/blob/master/src/testRunner/fourslashRunner.ts
57+
[1]: https://github.com/microsoft/TypeScript/blob/master/tests/cases/fourslash
58+
[2]: https://github.com/microsoft/TypeScript/blob/master/src/testRunner/runner.ts
59+
[3]: https://github.com/microsoft/TypeScript/blob/master/src/harness/fourslash.ts
6060
[4]: <src/harness/fourslash.ts - function runFourSlashTest(>
6161
[5]: <src/harness/fourslash.ts - function runFourSlashTestContent(>
6262
[5]: <src/harness/fourslash.ts - function parseTestData(>

compiler/systems/testing/README.md renamed to learn/systems/systems-testing.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
Yep, TypeScript has tests. Quite a lot, with a few different techniques:
44

5-
- [Unit Tests](./units.md)
6-
- [Baselines](./baselines.md)
7-
- [Fourslash](./fourslash.md)
5+
- [[Baselines|systems-baselines]]
6+
- [[Fourslash|systems-fourslash]]
87

98
## Commands worth knowing
109

compiler/systems/vscode/README.md renamed to learn/systems/systems-vscode.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ VS Code has three extensions related to TypeScript:
1414
A large amount of the work happens in the [`TypeScriptServiceClient`][1] which is the VS Code side of the
1515
TSServer.
1616

17-
[1]:
18-
https://github.com/microsoft/vscode/blob/master/extensions/typescript-language-features/src/typescriptServiceClient.ts#L75
17+
[1]: https://github.com/microsoft/vscode/blob/master/extensions/typescript-language-features/src/typescriptServiceClient.ts#L75

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"dependencies": {
33
"markdown-magic": "^1.0.0",
44
"typescript": "latest",
5-
"glob": "^7.1.6"
5+
"glob": "^7.1.6",
6+
"escape-regex-string": "^1.0.6"
67
},
78
"scripts": {
89
"build": "md-magic --path '**/*.md'",

scripts/convertRelativeLinksToHardcoded.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const glob = require("glob")
1616
const {readFileSync, writeFileSync, existsSync} = require("fs")
1717
const {join} = require("path")
1818
const { execSync } = require("child_process");
19+
const escapeRegex = require("escape-regex-string");
1920

2021
if (!process.argv[2]) throw new Error("Did not include a glob for markdown files to change")
2122

@@ -45,7 +46,7 @@ files.forEach(file => {
4546
const originalFile = readFileSync(join(repoPath, file), "utf8")
4647
if (!originalFile) throw new Error(`Could not find a file at '${join(repoPath, file)}'`)
4748

48-
const line = getLineNo(originalFile, new RegExp(searchTerm))
49+
const line = getLineNo(originalFile, new RegExp(escapeRegex(searchTerm)))
4950
const lineRef = line && line[0] && line[0].number ? `#L${line[0].number}`: ""
5051
const replacement = `: https://github.com/microsoft/TypeScript/blob/${repoHead.trim()}/${file}${lineRef}`
5152
content = content.replace(original, replacement)

0 commit comments

Comments
 (0)