Skip to content

Commit e149cc3

Browse files
committed
Merge remote-tracking branch 'upstream/main' into fix/46149
* upstream/main: (473 commits) Correct node used for isDefinition calculation (microsoft#48499) fix(48405): emit dummy members from a mapped type (microsoft#48481) CFA for dependent parameters typed by generic constraints (microsoft#48411) No contextual typing from return types for boolean literals (microsoft#48380) fix(47733): omit JSDoc comment template suggestion on node with existing JSDoc (microsoft#47748) Ensure that we copy empty NodeArrays during transform (microsoft#48490) Add a new compiler option `moduleSuffixes` to expand the node module resolver's search algorithm (microsoft#48189) feat(27615): Add missing member fix should work for type literals (microsoft#47212) Add label details to completion entry (microsoft#48429) Enable method signature completion for object literals (microsoft#48168) Fix string literal completions when a partially-typed string fixes inference to a type parameter (microsoft#48410) fix(48445): show errors on type-only import/export specifiers in JavaScript files (microsoft#48449) Fix newline inserted in empty block at end of formatting range (microsoft#48463) Prevent looking up symbol for as const from triggering an error (microsoft#48464) Revise accessor resolution logic and error reporting (microsoft#48459) fix(48166): skip checking module.exports in a truthiness call expression (microsoft#48337) LEGO: Merge pull request 48450 LEGO: Merge pull request 48436 fix(48031): show circularity error for self referential get accessor annotations (microsoft#48050) Revert "Fix contextual discrimination for omitted members (microsoft#43937)" (microsoft#48426) ...
2 parents 553dfef + 70585aa commit e149cc3

File tree

3,111 files changed

+184945
-103742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,111 files changed

+184945
-103742
lines changed

.devcontainer/devcontainer.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
}
88
},
99
"settings": {
10-
"terminal.integrated.shell.linux": "/bin/bash"
10+
"terminal.integrated.defaultProfile.linux": "bash",
11+
"terminal.integrated.profiles.linux": {
12+
"bash": {
13+
"path": "/bin/bash",
14+
"icon": "terminal-bash",
15+
},
16+
},
1117
},
1218
"extensions": [
1319
"dbaeumer.vscode-eslint"

.github/ISSUE_TEMPLATE/Bug_report.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ about: Create a report to help us improve TypeScript
44
title: ''
55
labels: ''
66
assignees: ''
7+
78
---
9+
810
# Bug Report
911

1012
<!--

.github/ISSUE_TEMPLATE/Feature_request.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ about: Suggest an idea
44
title: ''
55
labels: ''
66
assignees: ''
7+
78
---
9+
810
# Suggestion
911

1012
<!--

.github/ISSUE_TEMPLATE/lib_change.md

+58-55
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,58 @@
1-
---
2-
name: Library change
3-
about: Fix or improve issues with built-in type definitions like `lib.dom.d.ts`, `lib.es6.d.ts`, etc.
4-
title: ''
5-
labels: ''
6-
assignees: ''
7-
---
8-
# lib Update Request
9-
10-
<!--
11-
Please fill in each section completely. Thank you!
12-
13-
Are you here for one of these commonly-requested lib changes?
14-
* Object.keys - see https://stackoverflow.com/questions/55012174/
15-
* Array methods - see https://github.com/microsoft/TypeScript/issues/36554
16-
* parseInt, parseFloat, isFinite, isNaN, etc. - see https://github.com/microsoft/TypeScript/issues/4002
17-
18-
The DOM lib is maintained elsewhere and you can skip a step by filing issues/PRs for the DOM at that repo.
19-
See https://github.com/microsoft/TypeScript-DOM-lib-generator
20-
-->
21-
22-
## Configuration Check
23-
24-
<!--
25-
If you're missing common new methods like Array.includes, you may have a misconfigured project.
26-
Try setting `lib: "es2020"` and checking whether the type you want is present.
27-
You can diagnose further by running `tsc` with `--listFilesOnly` or `--showConfig`.
28-
29-
Conversely, if you are seeing built-in methods you expect to *not* see, check your 'lib' setting
30-
or review your dependencies for lib/reference directives that might be polluting
31-
your global scope. This is common when using the 'node' type library. See https://github.com/microsoft/TypeScript/issues/40184
32-
33-
Replace the text below:
34-
-->
35-
My compilation *target* is `ES2015` and my *lib* is `the default`.
36-
37-
## Missing / Incorrect Definition
38-
39-
<!--
40-
What property, method, function, etc is missing or incorrect?
41-
-->
42-
43-
## Sample Code
44-
45-
<!--
46-
What's some code using this that should work, but doesn't?
47-
-->
48-
49-
## Documentation Link
50-
51-
<!--
52-
Link to relevant documentation (e.g. MDN, W3C, ECMAScript Spec) to consult for this property.
53-
Note that lib.dom.d.ts intentionally does not include browser-specific extensions
54-
or early experimental features.
55-
-->
1+
---
2+
name: Library change
3+
about: Fix or improve issues with built-in type definitions like `lib.dom.d.ts`, `lib.es6.d.ts`,
4+
etc.
5+
title: ''
6+
labels: ''
7+
assignees: ''
8+
9+
---
10+
11+
# lib Update Request
12+
13+
<!--
14+
Please fill in each section completely. Thank you!
15+
16+
Are you here for one of these commonly-requested lib changes?
17+
* Object.keys - see https://stackoverflow.com/questions/55012174/
18+
* Array methods - see https://github.com/microsoft/TypeScript/issues/36554
19+
* parseInt, parseFloat, isFinite, isNaN, etc. - see https://github.com/microsoft/TypeScript/issues/4002
20+
21+
The DOM lib is maintained elsewhere and you can skip a step by filing issues/PRs for the DOM at that repo.
22+
See https://github.com/microsoft/TypeScript-DOM-lib-generator
23+
-->
24+
25+
## Configuration Check
26+
27+
<!--
28+
If you're missing common new methods like Array.includes, you may have a misconfigured project.
29+
Try setting `lib: "es2020"` and checking whether the type you want is present.
30+
You can diagnose further by running `tsc` with `--listFilesOnly` or `--showConfig`.
31+
32+
Conversely, if you are seeing built-in methods you expect to *not* see, check your 'lib' setting
33+
or review your dependencies for lib/reference directives that might be polluting
34+
your global scope. This is common when using the 'node' type library. See https://github.com/microsoft/TypeScript/issues/40184
35+
36+
Replace the text below:
37+
-->
38+
My compilation *target* is `ES2015` and my *lib* is `the default`.
39+
40+
## Missing / Incorrect Definition
41+
42+
<!--
43+
What property, method, function, etc is missing or incorrect?
44+
-->
45+
46+
## Sample Code
47+
48+
<!--
49+
What's some code using this that should work, but doesn't?
50+
-->
51+
52+
## Documentation Link
53+
54+
<!--
55+
Link to relevant documentation (e.g. MDN, W3C, ECMAScript Spec) to consult for this property.
56+
Note that lib.dom.d.ts intentionally does not include browser-specific extensions
57+
or early experimental features.
58+
-->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Types Not Correct in/with Callback
3+
about: TypeScript assuming the wrong type either after a callback runs, or within
4+
a callback
5+
title: ''
6+
labels: Duplicate
7+
assignees: ''
8+
9+
---
10+
11+
TypeScript has two narrowing-related behaviors that are both intentional. Please do not log additional bugs on this; see #9998 for more discussion.
12+
13+
The first is that *narrowings are not respected in callbacks*. In other words:
14+
```ts
15+
function fn(obj: { name: string | number }) {
16+
if (typeof obj.name === "string") {
17+
// Errors
18+
window.setTimeout(() => console.log(obj.name.toLowerCase());
19+
}
20+
}
21+
```
22+
This is intentional since the value of `obj.name` "could" change types between when the narrowing occurred and when the callback was invoke. See also #11498
23+
24+
The second is that *function calls do not reset narrowings*. In other words:
25+
```ts
26+
function fn(obj: { name: string | number }) {
27+
if (typeof obj.name === "string") {
28+
console.log("Here");
29+
// Does not error
30+
console.log(obj.name.toLowerCase());
31+
}
32+
}
33+
```
34+
This is intentional behavior, *even though `console.log` could have mutated obj*. This rule is consistently applied, even with the function is in-principle inspectable to actually have side effects
35+
```ts
36+
function fn(obj: { name: string | number }) {
37+
if (typeof obj.name === "string") {
38+
mut();
39+
// Does not error
40+
console.log(obj.name.toLowerCase());
41+
}
42+
43+
function mut() {
44+
obj.name = 42;
45+
}
46+
}
47+
```

.github/pr_owners.txt

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ jessetrinity
1212
minestarks
1313
armanio123
1414
gabritto
15+
jakebailey
16+
DanielRosenwasser

.github/pull_request_template.md

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ Please verify that:
99
1010
Refer to CONTRIBUTING.MD for more details.
1111
https://github.com/Microsoft/TypeScript/blob/main/CONTRIBUTING.md
12+
13+
** Please don't send typo fixes! **
14+
Please don't send a PR solely for the purpose of fixing a typo, unless that
15+
typo truly hurts understanding of the text. Each PR represents work for the
16+
maintainers, and that work should provide commensurate value.
17+
18+
If you're interested in sending a PR, the issue tracker has many issues marked `help wanted`.
1219
-->
1320

1421
Fixes #
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Ensures that repos which are related to TypeScript but may not have regular commits
2+
# have their GitHub Actions scheduled jobs still active due to the 6 week timeout
3+
# on OSS repos. This has already triggered a few times with microsoft/TypeScript-Make-Monaco-Builds
4+
# so, better to automate keeping on top of it.
5+
6+
name: Related Repo Commit Bumps
7+
8+
on:
9+
schedule:
10+
# Monthly, https://crontab.guru/#0_0_*_1-12_*
11+
- cron: '0 0 1 * *'
12+
workflow_dispatch: {}
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Configure git
20+
run: |
21+
git config --global user.email "[email protected]"
22+
git config --global user.name "TypeScript Bot"
23+
24+
- uses: actions/checkout@v2
25+
with:
26+
repository: 'microsoft/TypeScript-Website'
27+
path: 'ts-site'
28+
29+
- name: Push Commit to TS Website
30+
run: |
31+
cd ts-site
32+
git commit --allow-empty -m "Monthly Bump"
33+
git config --unset-all http.https://github.com/.extraheader
34+
git push https://${{ secrets.TS_BOT_GITHUB_TOKEN }}@github.com/microsoft/TypeScript-Website.git
35+
36+
- uses: actions/checkout@v2
37+
with:
38+
repository: 'microsoft/TypeScript-Make-Monaco-Builds'
39+
path: 'monaco-builds'
40+
41+
- name: Push Commit to TS Make Monaco Builds
42+
run: |
43+
cd monaco-builds
44+
git commit --allow-empty -m "Monthly Bump"
45+
git config --unset-all http.https://github.com/.extraheader
46+
git push https://${{ secrets.TS_BOT_GITHUB_TOKEN }}@github.com/microsoft/TypeScript-Make-Monaco-Builds.git

.vscode/launch.template.json

+2-10
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,15 @@
4848
"outFiles": [
4949
"${workspaceRoot}/built/local/run.js"
5050
],
51-
52-
// NOTE: To use this, you must switch the "type" above to "pwa-node". You may also need to follow the instructions
53-
// here: https://github.com/microsoft/vscode-js-debug#nightly-extension to use the js-debug nightly until
54-
// this feature is shipping in insiders or to a release:
55-
// "customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
51+
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue",
5652
},
5753
{
5854
// See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code
5955
"type": "node",
6056
"request": "attach",
6157
"name": "Attach to VS Code TS Server via Port",
6258
"processId": "${command:PickProcess}",
63-
64-
// NOTE: To use this, you must switch the "type" above to "pwa-node". You may also need to follow the instructions
65-
// here: https://github.com/microsoft/vscode-js-debug#nightly-extension to use the js-debug nightly until
66-
// this feature is shipping in insiders or to a release:
67-
// "customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
59+
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue",
6860
}
6961
]
7062
}

.vscode/settings.template.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
// contents into your existing settings.
33
{
44
"eslint.validate": [
5-
{
6-
"language": "typescript",
7-
"autoFix": true
8-
}
5+
"typescript"
96
],
107
"eslint.options": {
118
"rulePaths": ["./scripts/eslint/built/rules/"],
@@ -16,4 +13,4 @@
1613

1714
// To use the locally built compiler, after 'npm run build':
1815
// "typescript.tsdk": "built/local"
19-
}
16+
}

CONTRIBUTING.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Some search tips:
2020
## 3. Do you have a question?
2121

2222
The issue tracker is for **issues**, in other words, bugs and suggestions.
23-
If you have a *question*, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/typescript), [Gitter](https://gitter.im/Microsoft/TypeScript), your favorite search engine, or other resources.
23+
If you have a *question*, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/typescript), [Gitter](https://gitter.im/Microsoft/TypeScript), your favorite search engine, or other resources.
2424
Due to increased traffic, we can no longer answer questions in the issue tracker.
2525

2626
## 4. Did you find a bug?
@@ -81,6 +81,10 @@ If you prefer to develop using containers, this repository includes a [developme
8181

8282
The TypeScript repository is relatively large. To save some time, you might want to clone it without the repo's full history using `git clone --depth=1`.
8383

84+
### Filename too long on Windows
85+
86+
You might need to run `git config --global core.longpaths true` before cloning TypeScript on Windows.
87+
8488
### Using local builds
8589

8690
Run `gulp` to build a version of the compiler/language service that reflects changes you've made. You can then run `node <repo-root>/built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`.

lib/zh-cn/diagnosticMessages.generated.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
"Add_await_to_initializer_for_0_95084": "\"await\" 添加到 \"{0}\" 的初始值设定项",
131131
"Add_await_to_initializers_95089": "\"await\" 添加到初始值设定项",
132132
"Add_braces_to_arrow_function_95059": "向箭头函数添加大括号",
133-
"Add_class_tag_95102": "添加“@”标记",
133+
"Add_class_tag_95102": "添加“@class”标记",
134134
"Add_const_to_all_unresolved_variables_95082": "\"const\" 添加到所有未解析变量",
135135
"Add_const_to_unresolved_variable_95081": "\"const\" 添加到未解析的变量",
136136
"Add_default_import_0_to_existing_import_declaration_from_1_90033": "将默认导入 \"{0}\"\"{1}\" 添加到现有导入声明。",
@@ -154,7 +154,7 @@
154154
"Add_parameter_name_90034": "添加参数名称",
155155
"Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "将限定符添加到匹配成员名称的所有未解析变量",
156156
"Add_this_parameter_95104": "添加“此”参数。",
157-
"Add_this_tag_95103": "添加“@”标记",
157+
"Add_this_tag_95103": "添加“@this”标记",
158158
"Add_to_all_uncalled_decorators_95044": "\"()\" 添加到所有未调用的修饰器",
159159
"Add_ts_ignore_to_all_error_messages_95042": "\"@ts-ignore\" 添加到所有错误消息",
160160
"Add_undefined_to_a_type_when_accessed_using_an_index_6674": "使用索引访问时,将 “undefined” 添加到类型。",
@@ -1784,4 +1784,4 @@
17841784
"with_statements_are_not_allowed_in_strict_mode_1101": "严格模式下不允许使用 \"with\" 语句。",
17851785
"yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_t_7057": "\"yield\" 表达式隐式导致 \"any\" 类型,因为它的包含生成器缺少返回类型批注。",
17861786
"yield_expressions_cannot_be_used_in_a_parameter_initializer_2523": "不能在参数初始化表达式中使用 \"yield\" 表达式。"
1787-
}
1787+
}

0 commit comments

Comments
 (0)