Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix/46149
Browse files Browse the repository at this point in the history
* 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)
  ...
  • Loading branch information
sidharthv96 committed Apr 1, 2022
2 parents 553dfef + 70585aa commit e149cc3
Show file tree
Hide file tree
Showing 3,111 changed files with 184,945 additions and 103,742 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 7 additions & 1 deletion .devcontainer/devcontainer.json
Expand Up @@ -7,7 +7,13 @@
}
},
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash",
"icon": "terminal-bash",
},
},
},
"extensions": [
"dbaeumer.vscode-eslint"
Expand Down
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Expand Up @@ -4,7 +4,9 @@ about: Create a report to help us improve TypeScript
title: ''
labels: ''
assignees: ''

---

# Bug Report

<!--
Expand Down
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_request.md
Expand Up @@ -4,7 +4,9 @@ about: Suggest an idea
title: ''
labels: ''
assignees: ''

---

# Suggestion

<!--
Expand Down
113 changes: 58 additions & 55 deletions .github/ISSUE_TEMPLATE/lib_change.md
@@ -1,55 +1,58 @@
---
name: Library change
about: Fix or improve issues with built-in type definitions like `lib.dom.d.ts`, `lib.es6.d.ts`, etc.
title: ''
labels: ''
assignees: ''
---
# lib Update Request

<!--
Please fill in each section completely. Thank you!
Are you here for one of these commonly-requested lib changes?
* Object.keys - see https://stackoverflow.com/questions/55012174/
* Array methods - see https://github.com/microsoft/TypeScript/issues/36554
* parseInt, parseFloat, isFinite, isNaN, etc. - see https://github.com/microsoft/TypeScript/issues/4002
The DOM lib is maintained elsewhere and you can skip a step by filing issues/PRs for the DOM at that repo.
See https://github.com/microsoft/TypeScript-DOM-lib-generator
-->

## Configuration Check

<!--
If you're missing common new methods like Array.includes, you may have a misconfigured project.
Try setting `lib: "es2020"` and checking whether the type you want is present.
You can diagnose further by running `tsc` with `--listFilesOnly` or `--showConfig`.
Conversely, if you are seeing built-in methods you expect to *not* see, check your 'lib' setting
or review your dependencies for lib/reference directives that might be polluting
your global scope. This is common when using the 'node' type library. See https://github.com/microsoft/TypeScript/issues/40184
Replace the text below:
-->
My compilation *target* is `ES2015` and my *lib* is `the default`.

## Missing / Incorrect Definition

<!--
What property, method, function, etc is missing or incorrect?
-->

## Sample Code

<!--
What's some code using this that should work, but doesn't?
-->

## Documentation Link

<!--
Link to relevant documentation (e.g. MDN, W3C, ECMAScript Spec) to consult for this property.
Note that lib.dom.d.ts intentionally does not include browser-specific extensions
or early experimental features.
-->
---
name: Library change
about: Fix or improve issues with built-in type definitions like `lib.dom.d.ts`, `lib.es6.d.ts`,
etc.
title: ''
labels: ''
assignees: ''

---

# lib Update Request

<!--
Please fill in each section completely. Thank you!
Are you here for one of these commonly-requested lib changes?
* Object.keys - see https://stackoverflow.com/questions/55012174/
* Array methods - see https://github.com/microsoft/TypeScript/issues/36554
* parseInt, parseFloat, isFinite, isNaN, etc. - see https://github.com/microsoft/TypeScript/issues/4002
The DOM lib is maintained elsewhere and you can skip a step by filing issues/PRs for the DOM at that repo.
See https://github.com/microsoft/TypeScript-DOM-lib-generator
-->

## Configuration Check

<!--
If you're missing common new methods like Array.includes, you may have a misconfigured project.
Try setting `lib: "es2020"` and checking whether the type you want is present.
You can diagnose further by running `tsc` with `--listFilesOnly` or `--showConfig`.
Conversely, if you are seeing built-in methods you expect to *not* see, check your 'lib' setting
or review your dependencies for lib/reference directives that might be polluting
your global scope. This is common when using the 'node' type library. See https://github.com/microsoft/TypeScript/issues/40184
Replace the text below:
-->
My compilation *target* is `ES2015` and my *lib* is `the default`.

## Missing / Incorrect Definition

<!--
What property, method, function, etc is missing or incorrect?
-->

## Sample Code

<!--
What's some code using this that should work, but doesn't?
-->

## Documentation Link

<!--
Link to relevant documentation (e.g. MDN, W3C, ECMAScript Spec) to consult for this property.
Note that lib.dom.d.ts intentionally does not include browser-specific extensions
or early experimental features.
-->
47 changes: 47 additions & 0 deletions .github/ISSUE_TEMPLATE/types-not-correct-in-with-callback.md
@@ -0,0 +1,47 @@
---
name: Types Not Correct in/with Callback
about: TypeScript assuming the wrong type either after a callback runs, or within
a callback
title: ''
labels: Duplicate
assignees: ''

---

TypeScript has two narrowing-related behaviors that are both intentional. Please do not log additional bugs on this; see #9998 for more discussion.

The first is that *narrowings are not respected in callbacks*. In other words:
```ts
function fn(obj: { name: string | number }) {
if (typeof obj.name === "string") {
// Errors
window.setTimeout(() => console.log(obj.name.toLowerCase());
}
}
```
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
The second is that *function calls do not reset narrowings*. In other words:
```ts
function fn(obj: { name: string | number }) {
if (typeof obj.name === "string") {
console.log("Here");
// Does not error
console.log(obj.name.toLowerCase());
}
}
```
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
```ts
function fn(obj: { name: string | number }) {
if (typeof obj.name === "string") {
mut();
// Does not error
console.log(obj.name.toLowerCase());
}

function mut() {
obj.name = 42;
}
}
```
2 changes: 2 additions & 0 deletions .github/pr_owners.txt
Expand Up @@ -12,3 +12,5 @@ jessetrinity
minestarks
armanio123
gabritto
jakebailey
DanielRosenwasser
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Expand Up @@ -9,6 +9,13 @@ Please verify that:
Refer to CONTRIBUTING.MD for more details.
https://github.com/Microsoft/TypeScript/blob/main/CONTRIBUTING.md
** Please don't send typo fixes! **
Please don't send a PR solely for the purpose of fixing a typo, unless that
typo truly hurts understanding of the text. Each PR represents work for the
maintainers, and that work should provide commensurate value.
If you're interested in sending a PR, the issue tracker has many issues marked `help wanted`.
-->

Fixes #
46 changes: 46 additions & 0 deletions .github/workflows/ensure-related-repos-run-crons.yml
@@ -0,0 +1,46 @@
# Ensures that repos which are related to TypeScript but may not have regular commits
# have their GitHub Actions scheduled jobs still active due to the 6 week timeout
# on OSS repos. This has already triggered a few times with microsoft/TypeScript-Make-Monaco-Builds
# so, better to automate keeping on top of it.

name: Related Repo Commit Bumps

on:
schedule:
# Monthly, https://crontab.guru/#0_0_*_1-12_*
- cron: '0 0 1 * *'
workflow_dispatch: {}

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Configure git
run: |
git config --global user.email "typescriptbot@microsoft.com"
git config --global user.name "TypeScript Bot"
- uses: actions/checkout@v2
with:
repository: 'microsoft/TypeScript-Website'
path: 'ts-site'

- name: Push Commit to TS Website
run: |
cd ts-site
git commit --allow-empty -m "Monthly Bump"
git config --unset-all http.https://github.com/.extraheader
git push https://${{ secrets.TS_BOT_GITHUB_TOKEN }}@github.com/microsoft/TypeScript-Website.git
- uses: actions/checkout@v2
with:
repository: 'microsoft/TypeScript-Make-Monaco-Builds'
path: 'monaco-builds'

- name: Push Commit to TS Make Monaco Builds
run: |
cd monaco-builds
git commit --allow-empty -m "Monthly Bump"
git config --unset-all http.https://github.com/.extraheader
git push https://${{ secrets.TS_BOT_GITHUB_TOKEN }}@github.com/microsoft/TypeScript-Make-Monaco-Builds.git
12 changes: 2 additions & 10 deletions .vscode/launch.template.json
Expand Up @@ -48,23 +48,15 @@
"outFiles": [
"${workspaceRoot}/built/local/run.js"
],

// NOTE: To use this, you must switch the "type" above to "pwa-node". You may also need to follow the instructions
// here: https://github.com/microsoft/vscode-js-debug#nightly-extension to use the js-debug nightly until
// this feature is shipping in insiders or to a release:
// "customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue",
},
{
// See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code
"type": "node",
"request": "attach",
"name": "Attach to VS Code TS Server via Port",
"processId": "${command:PickProcess}",

// NOTE: To use this, you must switch the "type" above to "pwa-node". You may also need to follow the instructions
// here: https://github.com/microsoft/vscode-js-debug#nightly-extension to use the js-debug nightly until
// this feature is shipping in insiders or to a release:
// "customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue",
}
]
}
7 changes: 2 additions & 5 deletions .vscode/settings.template.json
Expand Up @@ -2,10 +2,7 @@
// contents into your existing settings.
{
"eslint.validate": [
{
"language": "typescript",
"autoFix": true
}
"typescript"
],
"eslint.options": {
"rulePaths": ["./scripts/eslint/built/rules/"],
Expand All @@ -16,4 +13,4 @@

// To use the locally built compiler, after 'npm run build':
// "typescript.tsdk": "built/local"
}
}
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -20,7 +20,7 @@ Some search tips:
## 3. Do you have a question?

The issue tracker is for **issues**, in other words, bugs and suggestions.
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.
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.
Due to increased traffic, we can no longer answer questions in the issue tracker.

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

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

### Filename too long on Windows

You might need to run `git config --global core.longpaths true` before cloning TypeScript on Windows.

### Using local builds

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`.
Expand Down
6 changes: 3 additions & 3 deletions lib/zh-cn/diagnosticMessages.generated.json
Expand Up @@ -130,7 +130,7 @@
"Add_await_to_initializer_for_0_95084": "\"await\" 添加到 \"{0}\" 的初始值设定项",
"Add_await_to_initializers_95089": "\"await\" 添加到初始值设定项",
"Add_braces_to_arrow_function_95059": "向箭头函数添加大括号",
"Add_class_tag_95102": "添加“@”标记",
"Add_class_tag_95102": "添加“@class”标记",
"Add_const_to_all_unresolved_variables_95082": "\"const\" 添加到所有未解析变量",
"Add_const_to_unresolved_variable_95081": "\"const\" 添加到未解析的变量",
"Add_default_import_0_to_existing_import_declaration_from_1_90033": "将默认导入 \"{0}\"\"{1}\" 添加到现有导入声明。",
Expand All @@ -154,7 +154,7 @@
"Add_parameter_name_90034": "添加参数名称",
"Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "将限定符添加到匹配成员名称的所有未解析变量",
"Add_this_parameter_95104": "添加“此”参数。",
"Add_this_tag_95103": "添加“@”标记",
"Add_this_tag_95103": "添加“@this”标记",
"Add_to_all_uncalled_decorators_95044": "\"()\" 添加到所有未调用的修饰器",
"Add_ts_ignore_to_all_error_messages_95042": "\"@ts-ignore\" 添加到所有错误消息",
"Add_undefined_to_a_type_when_accessed_using_an_index_6674": "使用索引访问时,将 “undefined” 添加到类型。",
Expand Down Expand Up @@ -1784,4 +1784,4 @@
"with_statements_are_not_allowed_in_strict_mode_1101": "严格模式下不允许使用 \"with\" 语句。",
"yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_t_7057": "\"yield\" 表达式隐式导致 \"any\" 类型,因为它的包含生成器缺少返回类型批注。",
"yield_expressions_cannot_be_used_in_a_parameter_initializer_2523": "不能在参数初始化表达式中使用 \"yield\" 表达式。"
}
}

0 comments on commit e149cc3

Please sign in to comment.