Skip to content

Commit

Permalink
Merge branch 'master' into removePromiseResolveValueOptionality
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Aug 20, 2020
2 parents b198eb6 + 598e9b2 commit ff5009c
Show file tree
Hide file tree
Showing 463 changed files with 13,270 additions and 3,151 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 13.x]
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/sync-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Sync branch with master
on:
repository_dispatch:
types: sync-branch
workflow_dispatch:
inputs:
branch_name:
description: 'Target Branch Name'
required: true

jobs:
build:
Expand All @@ -15,15 +20,15 @@ jobs:
node-version: 12.x
- uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.branch_name }}
ref: ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}
# This does a test post-merge and only pushes the result if the test succeeds
# required client_payload members:
# branch_name - the target branch
- run: |
git config user.email "[email protected]"
git config user.name "TypeScript Bot"
git fetch origin master
git merge master --no-ff
git merge origin/master --no-ff
npm install
npm test
git push
28 changes: 28 additions & 0 deletions .github/workflows/update-lkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Update LKG

on:
workflow_dispatch: {}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use node version 12
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/

- name: Configure Git and Update LKG
run: |
git config user.email "[email protected]"
git config user.name "TypeScript Bot"
npm install
gulp LKG
npm test
git diff
git add ./lib
git commit -m "Update LKG"
git push
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ language: node_js

node_js:
- 'node'
- '12'
- '10'
- '8'

env:
- workerCount=3 timeout=600000
Expand Down
2 changes: 1 addition & 1 deletion doc/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ namespace X { // Namespace named X
}
```

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

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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "https://www.typescriptlang.org/",
"version": "4.0.0",
"version": "4.1.0",
"license": "Apache-2.0",
"description": "TypeScript is a language for application scale JavaScript development",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion scripts/open-user-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runSequence([
["node", ["./node_modules/gulp/bin/gulp.js", "baseline-accept"]], // accept baselines
["git", ["checkout", "-b", branchName]], // create a branch
["git", ["add", "."]], // Add all changes
["git", ["commit", "-m", `"Update user baselines"`]], // Commit all changes
["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)
["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch
]);

Expand Down
43 changes: 35 additions & 8 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ namespace ts {
}

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

function jsdocTreatAsExported(node: Node) {
if (!isJSDocTypeAlias(node)) return false;
// jsdoc typedef handling is a bit of a doozy, but to summarize, treat the typedef as exported if:
// 1. It has an explicit name (since by default typedefs are always directly exported, either at the top level or in a container), or
if (!isJSDocEnumTag(node) && !!node.fullName) return true;
// 2. The thing a nameless typedef pulls its name from is implicitly a direct export (either by assignment or actual export flag).
const declName = getNameOfDeclaration(node);
if (!declName) return false;
if (isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true;
if (isDeclaration(declName.parent) && getCombinedModifierFlags(declName.parent) & ModifierFlags.Export) return true;
// This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should
// already have calculated and branched on most of this.
return false;
}

// All container nodes are kept on a linked list in declaration order. This list is used by
// the getLocalNameOfContainer function in the type checker to validate that the local name
// used for a container is unique.
Expand Down Expand Up @@ -837,7 +852,8 @@ namespace ts {
function isNarrowableReference(expr: Expression): boolean {
return expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.ThisKeyword || expr.kind === SyntaxKind.SuperKeyword ||
(isPropertyAccessExpression(expr) || isNonNullExpression(expr) || isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
isElementAccessExpression(expr) && isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression);
isElementAccessExpression(expr) && isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) ||
isAssignmentExpression(expr) && isNarrowableReference(expr.left);
}

function containsNarrowableReference(expr: Expression): boolean {
Expand Down Expand Up @@ -2461,7 +2477,7 @@ namespace ts {
if (isInJSFile(expr) &&
file.commonJsModuleIndicator &&
isModuleExportsAccessExpression(expr) &&
!lookupSymbolForNameWorker(blockScopeContainer, "module" as __String)) {
!lookupSymbolForName(blockScopeContainer, "module" as __String)) {
declareSymbol(file.locals!, /*parent*/ undefined, expr.expression,
SymbolFlags.FunctionScopedVariable | SymbolFlags.ModuleExports, SymbolFlags.FunctionScopedVariableExcludes);
}
Expand All @@ -2485,6 +2501,14 @@ namespace ts {
bindThisPropertyAssignment(node as BindablePropertyAssignmentExpression);
break;
case AssignmentDeclarationKind.Property:
const expression = ((node as BinaryExpression).left as AccessExpression).expression;
if (isInJSFile(node) && isIdentifier(expression)) {
const symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText);
if (isThisInitializedDeclaration(symbol?.valueDeclaration)) {
bindThisPropertyAssignment(node as BindablePropertyAssignmentExpression);
break;
}
}
bindSpecialPropertyAssignment(node as BindablePropertyAssignmentExpression);
break;
case AssignmentDeclarationKind.None:
Expand Down Expand Up @@ -3103,7 +3127,7 @@ namespace ts {

function lookupSymbolForPropertyAccess(node: BindableStaticNameExpression, lookupContainer: Node = container): Symbol | undefined {
if (isIdentifier(node)) {
return lookupSymbolForNameWorker(lookupContainer, node.escapedText);
return lookupSymbolForName(lookupContainer, node.escapedText);
}
else {
const symbol = lookupSymbolForPropertyAccess(node.expression);
Expand Down Expand Up @@ -3185,7 +3209,10 @@ namespace ts {
}

if (!isBindingPattern(node.name)) {
if (isBlockOrCatchScoped(node)) {
if (isInJSFile(node) && isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !getJSDocTypeTag(node)) {
declareSymbolAndAddToSymbolTable(node as Declaration, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
}
else if (isBlockOrCatchScoped(node)) {
bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
}
else if (isParameterDeclaration(node)) {
Expand Down Expand Up @@ -3403,7 +3430,7 @@ namespace ts {
return true;
}
else if (isIdentifier(node)) {
const symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
const symbol = lookupSymbolForName(sourceFile, node.escapedText);
if (!!symbol && !!symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
const init = symbol.valueDeclaration.initializer;
q.push(init);
Expand All @@ -3417,7 +3444,7 @@ namespace ts {
return false;
}

function lookupSymbolForNameWorker(container: Node, name: __String): Symbol | undefined {
function lookupSymbolForName(container: Node, name: __String): Symbol | undefined {
const local = container.locals && container.locals.get(name);
if (local) {
return local.exportSymbol || local;
Expand Down
Loading

0 comments on commit ff5009c

Please sign in to comment.