Skip to content

Commit 09801d4

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: (22 commits) Small fix in `getIsContextSensitiveAssignmentOrContextType` Simplify `visitObjectLiteralExpression` Fix handling of `aruments` in the emitter Fix declaration emit for property references of imported object literal types (microsoft#39055) Fix casing for wild card keys for implicit globs to get wild card directories to watch (microsoft#39049) DOM update 2020-06-12 fix(a11y): make ISSUE_TEMPLATE/Bug_report.md more accessible for folks with screen readers (microsoft#39013) Update request-pr-review script to latest version of octokit (microsoft#39031) pin version of octokit skip implements types with no symbols isDynamicName skips parentheses for element access Allow `e: unknown` in `catch` arguments Serialize (noncontextual) keyword named namespace members with export declarations in both declaration emitters (microsoft#38982) Patch to use this.timeout() > 0 rather than this.enableTimeout() to work with mocha 8+ Handle missing return type nodes and nested type references missing type arguments in existing jsdoc node serialization (microsoft#39011) Add containerName to CallHierarchyItem (microsoft#38997) Fix isSameEntityName (microsoft#38999) Fix typo for 'blocklist' (microsoft#39001) remove errant tab Switch to isSymbolAccessible for both. ...
2 parents e67ba68 + 0432954 commit 09801d4

File tree

117 files changed

+5423
-590
lines changed

Some content is hidden

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

117 files changed

+5423
-590
lines changed

.github/ISSUE_TEMPLATE/Bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ assignees: ''
77

88
---
99

10-
<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨
10+
<!-- 🚨 STOP 🚨 STOP 🚨 STOP 🚨
1111
1212
Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section!
1313

scripts/request-pr-review.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ main().catch(console.error);
4242

4343
async function main() {
4444
const gh = new Octokit({ auth: options.token });
45-
const response = await gh.pulls.createReviewRequest({
45+
const response = await gh.pulls.requestReviewers({
4646
owner: options.owner,
4747
repo: options.repo,
4848
pull_number,

src/compiler/checker.ts

Lines changed: 181 additions & 117 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,10 @@ namespace ts {
31203120
};
31213121
}
31223122
if (isImplicitGlob(spec)) {
3123-
return { key: spec, flags: WatchDirectoryFlags.Recursive };
3123+
return {
3124+
key: useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec),
3125+
flags: WatchDirectoryFlags.Recursive
3126+
};
31243127
}
31253128
return undefined;
31263129
}

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@
619619
"category": "Error",
620620
"code": 1195
621621
},
622-
"Catch clause variable cannot have a type annotation.": {
622+
"Catch clause variable type annotation must be 'any' or 'unknown' if specified.": {
623623
"category": "Error",
624624
"code": 1196
625625
},

src/compiler/transformers/declarations.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,18 +1180,36 @@ namespace ts {
11801180
fakespace.parent = enclosingDeclaration as SourceFile | NamespaceDeclaration;
11811181
fakespace.locals = createSymbolTable(props);
11821182
fakespace.symbol = props[0].parent!;
1183-
const declarations = mapDefined(props, p => {
1183+
const exportMappings: [Identifier, string][] = [];
1184+
const declarations: (VariableStatement | ExportDeclaration)[] = mapDefined(props, p => {
11841185
if (!isPropertyAccessExpression(p.valueDeclaration)) {
11851186
return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them)
11861187
}
11871188
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
11881189
const type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace, declarationEmitNodeBuilderFlags, symbolTracker);
11891190
getSymbolAccessibilityDiagnostic = oldDiag;
1190-
const varDecl = createVariableDeclaration(unescapeLeadingUnderscores(p.escapedName), type, /*initializer*/ undefined);
1191-
return createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([varDecl]));
1191+
const nameStr = unescapeLeadingUnderscores(p.escapedName);
1192+
const isNonContextualKeywordName = isStringANonContextualKeyword(nameStr);
1193+
const name = isNonContextualKeywordName ? getGeneratedNameForNode(p.valueDeclaration) : createIdentifier(nameStr);
1194+
if (isNonContextualKeywordName) {
1195+
exportMappings.push([name, nameStr]);
1196+
}
1197+
const varDecl = createVariableDeclaration(name, type, /*initializer*/ undefined);
1198+
return createVariableStatement(isNonContextualKeywordName ? undefined : [createToken(SyntaxKind.ExportKeyword)], createVariableDeclarationList([varDecl]));
11921199
});
1200+
if (!exportMappings.length) {
1201+
forEach(declarations, d => d.modifiers = undefined);
1202+
}
1203+
else {
1204+
declarations.push(createExportDeclaration(
1205+
/*decorators*/ undefined,
1206+
/*modifiers*/ undefined,
1207+
createNamedExports(map(exportMappings, ([gen, exp]) => {
1208+
return createExportSpecifier(gen, exp);
1209+
}))
1210+
));
1211+
}
11931212
const namespaceDecl = createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name!, createModuleBlock(declarations), NodeFlags.Namespace);
1194-
11951213
if (!hasEffectiveModifier(clean, ModifierFlags.Default)) {
11961214
return [clean, namespaceDecl];
11971215
}

src/compiler/transformers/es2015.ts

Lines changed: 36 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,10 @@ namespace ts {
583583
if (!convertedLoopState) {
584584
return node;
585585
}
586-
if (isGeneratedIdentifier(node)) {
587-
return node;
588-
}
589-
if (node.escapedText !== "arguments" || !resolver.isArgumentsLocalBinding(node)) {
590-
return node;
586+
if (resolver.isArgumentsLocalBinding(node)) {
587+
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments"));
591588
}
592-
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments"));
589+
return node;
593590
}
594591

595592
function visitBreakOrContinueStatement(node: BreakOrContinueStatement): Statement {
@@ -2569,62 +2566,54 @@ namespace ts {
25692566
* @param node An ObjectLiteralExpression node.
25702567
*/
25712568
function visitObjectLiteralExpression(node: ObjectLiteralExpression): Expression {
2572-
// We are here because a ComputedPropertyName was used somewhere in the expression.
25732569
const properties = node.properties;
2574-
const numProperties = properties.length;
25752570

25762571
// Find the first computed property.
25772572
// Everything until that point can be emitted as part of the initial object literal.
2578-
let numInitialProperties = numProperties;
2579-
let numInitialPropertiesWithoutYield = numProperties;
2580-
for (let i = 0; i < numProperties; i++) {
2573+
let numInitialProperties = -1, hasComputed = false;
2574+
for (let i = 0; i < properties.length; i++) {
25812575
const property = properties[i];
2582-
if ((property.transformFlags & TransformFlags.ContainsYield && hierarchyFacts & HierarchyFacts.AsyncFunctionBody)
2583-
&& i < numInitialPropertiesWithoutYield) {
2584-
numInitialPropertiesWithoutYield = i;
2585-
}
2586-
if (Debug.checkDefined(property.name).kind === SyntaxKind.ComputedPropertyName) {
2576+
if ((property.transformFlags & TransformFlags.ContainsYield &&
2577+
hierarchyFacts & HierarchyFacts.AsyncFunctionBody)
2578+
|| (hasComputed = Debug.checkDefined(property.name).kind === SyntaxKind.ComputedPropertyName)) {
25872579
numInitialProperties = i;
25882580
break;
25892581
}
25902582
}
25912583

2592-
if (numInitialProperties !== numProperties) {
2593-
if (numInitialPropertiesWithoutYield < numInitialProperties) {
2594-
numInitialProperties = numInitialPropertiesWithoutYield;
2595-
}
2584+
if (numInitialProperties < 0) {
2585+
return visitEachChild(node, visitor, context);
2586+
}
25962587

2597-
// For computed properties, we need to create a unique handle to the object
2598-
// literal so we can modify it without risking internal assignments tainting the object.
2599-
const temp = createTempVariable(hoistVariableDeclaration);
2588+
// For computed properties, we need to create a unique handle to the object
2589+
// literal so we can modify it without risking internal assignments tainting the object.
2590+
const temp = createTempVariable(hoistVariableDeclaration);
26002591

2601-
// Write out the first non-computed properties, then emit the rest through indexing on the temp variable.
2602-
const expressions: Expression[] = [];
2603-
const assignment = createAssignment(
2604-
temp,
2605-
setEmitFlags(
2606-
createObjectLiteral(
2607-
visitNodes(properties, visitor, isObjectLiteralElementLike, 0, numInitialProperties),
2608-
node.multiLine
2609-
),
2610-
EmitFlags.Indented
2611-
)
2612-
);
2592+
// Write out the first non-computed properties, then emit the rest through indexing on the temp variable.
2593+
const expressions: Expression[] = [];
2594+
const assignment = createAssignment(
2595+
temp,
2596+
setEmitFlags(
2597+
createObjectLiteral(
2598+
visitNodes(properties, visitor, isObjectLiteralElementLike, 0, numInitialProperties),
2599+
node.multiLine
2600+
),
2601+
hasComputed ? EmitFlags.Indented : 0
2602+
)
2603+
);
26132604

2614-
if (node.multiLine) {
2615-
startOnNewLine(assignment);
2616-
}
2605+
if (node.multiLine) {
2606+
startOnNewLine(assignment);
2607+
}
26172608

2618-
expressions.push(assignment);
2609+
expressions.push(assignment);
26192610

2620-
addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
2611+
addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
26212612

2622-
// We need to clone the temporary identifier so that we can write it on a
2623-
// new line
2624-
expressions.push(node.multiLine ? startOnNewLine(getMutableClone(temp)) : temp);
2625-
return inlineExpressions(expressions);
2626-
}
2627-
return visitEachChild(node, visitor, context);
2613+
// We need to clone the temporary identifier so that we can write it on a
2614+
// new line
2615+
expressions.push(node.multiLine ? startOnNewLine(getMutableClone(temp)) : temp);
2616+
return inlineExpressions(expressions);
26282617
}
26292618

26302619
interface ForStatementWithConvertibleInitializer extends ForStatement {
@@ -3517,7 +3506,7 @@ namespace ts {
35173506
return setTextRange(
35183507
createPropertyAssignment(
35193508
node.name,
3520-
getSynthesizedClone(node.name)
3509+
visitIdentifier(getSynthesizedClone(node.name))
35213510
),
35223511
/*location*/ node
35233512
);

src/compiler/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ namespace ts {
21052105
*/
21062106
function isSameEntityName(name: Expression, initializer: Expression): boolean {
21072107
if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
2108-
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name);
2108+
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
21092109
}
21102110
if (isIdentifier(name) && isLiteralLikeAccess(initializer) &&
21112111
(initializer.expression.kind === SyntaxKind.ThisKeyword ||
@@ -3061,7 +3061,7 @@ namespace ts {
30613061
if (!(name.kind === SyntaxKind.ComputedPropertyName || name.kind === SyntaxKind.ElementAccessExpression)) {
30623062
return false;
30633063
}
3064-
const expr = isElementAccessExpression(name) ? name.argumentExpression : name.expression;
3064+
const expr = isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
30653065
return !isStringOrNumericLiteralLike(expr) &&
30663066
!isSignedNumericLiteral(expr) &&
30673067
!isWellKnownSymbolSyntactically(expr);

src/compiler/utilitiesPublic.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,8 @@ namespace ts {
589589
(isFunctionExpression(declaration) || isClassExpression(declaration) ? getAssignedName(declaration) : undefined);
590590
}
591591

592-
function getAssignedName(node: Node): DeclarationName | undefined {
592+
/*@internal*/
593+
export function getAssignedName(node: Node): DeclarationName | undefined {
593594
if (!node.parent) {
594595
return undefined;
595596
}

src/harness/fourslashImpl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3440,6 +3440,9 @@ namespace FourSlash {
34403440
let text = "";
34413441
text += `${prefix}╭ name: ${callHierarchyItem.name}\n`;
34423442
text += `${prefix}├ kind: ${callHierarchyItem.kind}\n`;
3443+
if (callHierarchyItem.containerName) {
3444+
text += `${prefix}├ containerName: ${callHierarchyItem.containerName}\n`;
3445+
}
34433446
text += `${prefix}├ file: ${callHierarchyItem.file}\n`;
34443447
text += `${prefix}├ span:\n`;
34453448
text += this.formatCallHierarchyItemSpan(file, callHierarchyItem.span, `${prefix}│ `);

src/harness/harnessUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ namespace Utils {
218218
case "symbolCount":
219219
case "identifierCount":
220220
case "scriptSnapshot":
221-
// Blockist of items we never put in the baseline file.
221+
// Blocklist of items we never put in the baseline file.
222222
break;
223223

224224
case "originalKeywordKind":

0 commit comments

Comments
 (0)