Skip to content

Commit ff5009c

Browse files
committed
Merge branch 'master' into removePromiseResolveValueOptionality
2 parents b198eb6 + 598e9b2 commit ff5009c

File tree

463 files changed

+13270
-3151
lines changed

Some content is hidden

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

463 files changed

+13270
-3151
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [10.x, 12.x, 13.x]
19+
node-version: [10.x, 12.x, 14.x]
2020

2121
steps:
2222
- uses: actions/checkout@v2

.github/workflows/sync-branch.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: Sync branch with master
33
on:
44
repository_dispatch:
55
types: sync-branch
6+
workflow_dispatch:
7+
inputs:
8+
branch_name:
9+
description: 'Target Branch Name'
10+
required: true
611

712
jobs:
813
build:
@@ -15,15 +20,15 @@ jobs:
1520
node-version: 12.x
1621
- uses: actions/checkout@v2
1722
with:
18-
ref: ${{ github.event.client_payload.branch_name }}
23+
ref: ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}
1924
# This does a test post-merge and only pushes the result if the test succeeds
2025
# required client_payload members:
2126
# branch_name - the target branch
2227
- run: |
2328
git config user.email "[email protected]"
2429
git config user.name "TypeScript Bot"
2530
git fetch origin master
26-
git merge master --no-ff
31+
git merge origin/master --no-ff
2732
npm install
2833
npm test
2934
git push

.github/workflows/update-lkg.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Update LKG
2+
3+
on:
4+
workflow_dispatch: {}
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Use node version 12
13+
uses: actions/setup-node@v1
14+
with:
15+
node-version: 12
16+
registry-url: https://registry.npmjs.org/
17+
18+
- name: Configure Git and Update LKG
19+
run: |
20+
git config user.email "[email protected]"
21+
git config user.name "TypeScript Bot"
22+
npm install
23+
gulp LKG
24+
npm test
25+
git diff
26+
git add ./lib
27+
git commit -m "Update LKG"
28+
git push

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ language: node_js
22

33
node_js:
44
- 'node'
5+
- '12'
56
- '10'
6-
- '8'
77

88
env:
99
- workerCount=3 timeout=600000

doc/spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ namespace X { // Namespace named X
903903
}
904904
```
905905

906-
A name that denotes a value has an associated type (section [3](#3)) and can be referenced in expressions (section [4.3](#4.3)). A name that denotes a type can be used by itself in a type reference or on the right hand side of a dot in a type reference ([3.8.2](#3.8.2)). A name that denotes a namespace can be used one the left hand side of a dot in a type reference.
906+
A name that denotes a value has an associated type (section [3](#3)) and can be referenced in expressions (section [4.3](#4.3)). A name that denotes a type can be used by itself in a type reference or on the right hand side of a dot in a type reference ([3.8.2](#3.8.2)). A name that denotes a namespace can be used on the left hand side of a dot in a type reference.
907907

908908
When a name with multiple meanings is referenced, the context in which the reference occurs determines the meaning. For example:
909909

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "https://www.typescriptlang.org/",
5-
"version": "4.0.0",
5+
"version": "4.1.0",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [

scripts/open-user-pr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runSequence([
2222
["node", ["./node_modules/gulp/bin/gulp.js", "baseline-accept"]], // accept baselines
2323
["git", ["checkout", "-b", branchName]], // create a branch
2424
["git", ["add", "."]], // Add all changes
25-
["git", ["commit", "-m", `"Update user baselines"`]], // Commit all changes
25+
["git", ["commit", "-m", `"Update user baselines${+process.env.SOURCE_ISSUE === 33716 ? " +cc @sandersn" : ""}"`]], // Commit all changes (ping nathan if we would post to CI thread)
2626
["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch
2727
]);
2828

src/compiler/binder.ts

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ namespace ts {
541541
}
542542

543543
function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol {
544-
const hasExportModifier = getCombinedModifierFlags(node) & ModifierFlags.Export;
544+
const hasExportModifier = !!(getCombinedModifierFlags(node) & ModifierFlags.Export) || jsdocTreatAsExported(node);
545545
if (symbolFlags & SymbolFlags.Alias) {
546546
if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) {
547547
return declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes);
@@ -567,7 +567,7 @@ namespace ts {
567567
// and this case is specially handled. Module augmentations should only be merged with original module definition
568568
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
569569
if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
570-
if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypeAlias(node)) {
570+
if (!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) {
571571
if (!container.locals || (hasSyntacticModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
572572
return declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
573573
}
@@ -583,6 +583,21 @@ namespace ts {
583583
}
584584
}
585585

586+
function jsdocTreatAsExported(node: Node) {
587+
if (!isJSDocTypeAlias(node)) return false;
588+
// jsdoc typedef handling is a bit of a doozy, but to summarize, treat the typedef as exported if:
589+
// 1. It has an explicit name (since by default typedefs are always directly exported, either at the top level or in a container), or
590+
if (!isJSDocEnumTag(node) && !!node.fullName) return true;
591+
// 2. The thing a nameless typedef pulls its name from is implicitly a direct export (either by assignment or actual export flag).
592+
const declName = getNameOfDeclaration(node);
593+
if (!declName) return false;
594+
if (isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true;
595+
if (isDeclaration(declName.parent) && getCombinedModifierFlags(declName.parent) & ModifierFlags.Export) return true;
596+
// This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should
597+
// already have calculated and branched on most of this.
598+
return false;
599+
}
600+
586601
// All container nodes are kept on a linked list in declaration order. This list is used by
587602
// the getLocalNameOfContainer function in the type checker to validate that the local name
588603
// used for a container is unique.
@@ -837,7 +852,8 @@ namespace ts {
837852
function isNarrowableReference(expr: Expression): boolean {
838853
return expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.ThisKeyword || expr.kind === SyntaxKind.SuperKeyword ||
839854
(isPropertyAccessExpression(expr) || isNonNullExpression(expr) || isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
840-
isElementAccessExpression(expr) && isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression);
855+
isElementAccessExpression(expr) && isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) ||
856+
isAssignmentExpression(expr) && isNarrowableReference(expr.left);
841857
}
842858

843859
function containsNarrowableReference(expr: Expression): boolean {
@@ -2461,7 +2477,7 @@ namespace ts {
24612477
if (isInJSFile(expr) &&
24622478
file.commonJsModuleIndicator &&
24632479
isModuleExportsAccessExpression(expr) &&
2464-
!lookupSymbolForNameWorker(blockScopeContainer, "module" as __String)) {
2480+
!lookupSymbolForName(blockScopeContainer, "module" as __String)) {
24652481
declareSymbol(file.locals!, /*parent*/ undefined, expr.expression,
24662482
SymbolFlags.FunctionScopedVariable | SymbolFlags.ModuleExports, SymbolFlags.FunctionScopedVariableExcludes);
24672483
}
@@ -2485,6 +2501,14 @@ namespace ts {
24852501
bindThisPropertyAssignment(node as BindablePropertyAssignmentExpression);
24862502
break;
24872503
case AssignmentDeclarationKind.Property:
2504+
const expression = ((node as BinaryExpression).left as AccessExpression).expression;
2505+
if (isInJSFile(node) && isIdentifier(expression)) {
2506+
const symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText);
2507+
if (isThisInitializedDeclaration(symbol?.valueDeclaration)) {
2508+
bindThisPropertyAssignment(node as BindablePropertyAssignmentExpression);
2509+
break;
2510+
}
2511+
}
24882512
bindSpecialPropertyAssignment(node as BindablePropertyAssignmentExpression);
24892513
break;
24902514
case AssignmentDeclarationKind.None:
@@ -3103,7 +3127,7 @@ namespace ts {
31033127

31043128
function lookupSymbolForPropertyAccess(node: BindableStaticNameExpression, lookupContainer: Node = container): Symbol | undefined {
31053129
if (isIdentifier(node)) {
3106-
return lookupSymbolForNameWorker(lookupContainer, node.escapedText);
3130+
return lookupSymbolForName(lookupContainer, node.escapedText);
31073131
}
31083132
else {
31093133
const symbol = lookupSymbolForPropertyAccess(node.expression);
@@ -3185,7 +3209,10 @@ namespace ts {
31853209
}
31863210

31873211
if (!isBindingPattern(node.name)) {
3188-
if (isBlockOrCatchScoped(node)) {
3212+
if (isInJSFile(node) && isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !getJSDocTypeTag(node)) {
3213+
declareSymbolAndAddToSymbolTable(node as Declaration, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
3214+
}
3215+
else if (isBlockOrCatchScoped(node)) {
31893216
bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
31903217
}
31913218
else if (isParameterDeclaration(node)) {
@@ -3403,7 +3430,7 @@ namespace ts {
34033430
return true;
34043431
}
34053432
else if (isIdentifier(node)) {
3406-
const symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
3433+
const symbol = lookupSymbolForName(sourceFile, node.escapedText);
34073434
if (!!symbol && !!symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
34083435
const init = symbol.valueDeclaration.initializer;
34093436
q.push(init);
@@ -3417,7 +3444,7 @@ namespace ts {
34173444
return false;
34183445
}
34193446

3420-
function lookupSymbolForNameWorker(container: Node, name: __String): Symbol | undefined {
3447+
function lookupSymbolForName(container: Node, name: __String): Symbol | undefined {
34213448
const local = container.locals && container.locals.get(name);
34223449
if (local) {
34233450
return local.exportSymbol || local;

0 commit comments

Comments
 (0)