Skip to content

Commit b032aa5

Browse files
committed
Merge branch 'main' into gabritto/issue46590
2 parents 5b0d86d + bf0eef4 commit b032aa5

File tree

591 files changed

+15775
-18214
lines changed

Some content is hidden

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

591 files changed

+15775
-18214
lines changed

.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+
```

0 commit comments

Comments
 (0)