Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* 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.
  ...
  • Loading branch information
cangSDARM committed Jun 15, 2020
2 parents e67ba68 + 0432954 commit 09801d4
Show file tree
Hide file tree
Showing 117 changed files with 5,423 additions and 590 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ assignees: ''

---

<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨
<!-- 🚨 STOP 🚨 STOP 🚨 STOP 🚨
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!
Expand Down
2 changes: 1 addition & 1 deletion scripts/request-pr-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ main().catch(console.error);

async function main() {
const gh = new Octokit({ auth: options.token });
const response = await gh.pulls.createReviewRequest({
const response = await gh.pulls.requestReviewers({
owner: options.owner,
repo: options.repo,
pull_number,
Expand Down
298 changes: 181 additions & 117 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3120,7 +3120,10 @@ namespace ts {
};
}
if (isImplicitGlob(spec)) {
return { key: spec, flags: WatchDirectoryFlags.Recursive };
return {
key: useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec),
flags: WatchDirectoryFlags.Recursive
};
}
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@
"category": "Error",
"code": 1195
},
"Catch clause variable cannot have a type annotation.": {
"Catch clause variable type annotation must be 'any' or 'unknown' if specified.": {
"category": "Error",
"code": 1196
},
Expand Down
26 changes: 22 additions & 4 deletions src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,18 +1180,36 @@ namespace ts {
fakespace.parent = enclosingDeclaration as SourceFile | NamespaceDeclaration;
fakespace.locals = createSymbolTable(props);
fakespace.symbol = props[0].parent!;
const declarations = mapDefined(props, p => {
const exportMappings: [Identifier, string][] = [];
const declarations: (VariableStatement | ExportDeclaration)[] = mapDefined(props, p => {
if (!isPropertyAccessExpression(p.valueDeclaration)) {
return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them)
}
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
const type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace, declarationEmitNodeBuilderFlags, symbolTracker);
getSymbolAccessibilityDiagnostic = oldDiag;
const varDecl = createVariableDeclaration(unescapeLeadingUnderscores(p.escapedName), type, /*initializer*/ undefined);
return createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([varDecl]));
const nameStr = unescapeLeadingUnderscores(p.escapedName);
const isNonContextualKeywordName = isStringANonContextualKeyword(nameStr);
const name = isNonContextualKeywordName ? getGeneratedNameForNode(p.valueDeclaration) : createIdentifier(nameStr);
if (isNonContextualKeywordName) {
exportMappings.push([name, nameStr]);
}
const varDecl = createVariableDeclaration(name, type, /*initializer*/ undefined);
return createVariableStatement(isNonContextualKeywordName ? undefined : [createToken(SyntaxKind.ExportKeyword)], createVariableDeclarationList([varDecl]));
});
if (!exportMappings.length) {
forEach(declarations, d => d.modifiers = undefined);
}
else {
declarations.push(createExportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
createNamedExports(map(exportMappings, ([gen, exp]) => {
return createExportSpecifier(gen, exp);
}))
));
}
const namespaceDecl = createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name!, createModuleBlock(declarations), NodeFlags.Namespace);

if (!hasEffectiveModifier(clean, ModifierFlags.Default)) {
return [clean, namespaceDecl];
}
Expand Down
83 changes: 36 additions & 47 deletions src/compiler/transformers/es2015.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,10 @@ namespace ts {
if (!convertedLoopState) {
return node;
}
if (isGeneratedIdentifier(node)) {
return node;
}
if (node.escapedText !== "arguments" || !resolver.isArgumentsLocalBinding(node)) {
return node;
if (resolver.isArgumentsLocalBinding(node)) {
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments"));
}
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments"));
return node;
}

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

// Find the first computed property.
// Everything until that point can be emitted as part of the initial object literal.
let numInitialProperties = numProperties;
let numInitialPropertiesWithoutYield = numProperties;
for (let i = 0; i < numProperties; i++) {
let numInitialProperties = -1, hasComputed = false;
for (let i = 0; i < properties.length; i++) {
const property = properties[i];
if ((property.transformFlags & TransformFlags.ContainsYield && hierarchyFacts & HierarchyFacts.AsyncFunctionBody)
&& i < numInitialPropertiesWithoutYield) {
numInitialPropertiesWithoutYield = i;
}
if (Debug.checkDefined(property.name).kind === SyntaxKind.ComputedPropertyName) {
if ((property.transformFlags & TransformFlags.ContainsYield &&
hierarchyFacts & HierarchyFacts.AsyncFunctionBody)
|| (hasComputed = Debug.checkDefined(property.name).kind === SyntaxKind.ComputedPropertyName)) {
numInitialProperties = i;
break;
}
}

if (numInitialProperties !== numProperties) {
if (numInitialPropertiesWithoutYield < numInitialProperties) {
numInitialProperties = numInitialPropertiesWithoutYield;
}
if (numInitialProperties < 0) {
return visitEachChild(node, visitor, context);
}

// For computed properties, we need to create a unique handle to the object
// literal so we can modify it without risking internal assignments tainting the object.
const temp = createTempVariable(hoistVariableDeclaration);
// For computed properties, we need to create a unique handle to the object
// literal so we can modify it without risking internal assignments tainting the object.
const temp = createTempVariable(hoistVariableDeclaration);

// Write out the first non-computed properties, then emit the rest through indexing on the temp variable.
const expressions: Expression[] = [];
const assignment = createAssignment(
temp,
setEmitFlags(
createObjectLiteral(
visitNodes(properties, visitor, isObjectLiteralElementLike, 0, numInitialProperties),
node.multiLine
),
EmitFlags.Indented
)
);
// Write out the first non-computed properties, then emit the rest through indexing on the temp variable.
const expressions: Expression[] = [];
const assignment = createAssignment(
temp,
setEmitFlags(
createObjectLiteral(
visitNodes(properties, visitor, isObjectLiteralElementLike, 0, numInitialProperties),
node.multiLine
),
hasComputed ? EmitFlags.Indented : 0
)
);

if (node.multiLine) {
startOnNewLine(assignment);
}
if (node.multiLine) {
startOnNewLine(assignment);
}

expressions.push(assignment);
expressions.push(assignment);

addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
addObjectLiteralMembers(expressions, node, temp, numInitialProperties);

// We need to clone the temporary identifier so that we can write it on a
// new line
expressions.push(node.multiLine ? startOnNewLine(getMutableClone(temp)) : temp);
return inlineExpressions(expressions);
}
return visitEachChild(node, visitor, context);
// We need to clone the temporary identifier so that we can write it on a
// new line
expressions.push(node.multiLine ? startOnNewLine(getMutableClone(temp)) : temp);
return inlineExpressions(expressions);
}

interface ForStatementWithConvertibleInitializer extends ForStatement {
Expand Down Expand Up @@ -3517,7 +3506,7 @@ namespace ts {
return setTextRange(
createPropertyAssignment(
node.name,
getSynthesizedClone(node.name)
visitIdentifier(getSynthesizedClone(node.name))
),
/*location*/ node
);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,7 @@ namespace ts {
*/
function isSameEntityName(name: Expression, initializer: Expression): boolean {
if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name);
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
}
if (isIdentifier(name) && isLiteralLikeAccess(initializer) &&
(initializer.expression.kind === SyntaxKind.ThisKeyword ||
Expand Down Expand Up @@ -3061,7 +3061,7 @@ namespace ts {
if (!(name.kind === SyntaxKind.ComputedPropertyName || name.kind === SyntaxKind.ElementAccessExpression)) {
return false;
}
const expr = isElementAccessExpression(name) ? name.argumentExpression : name.expression;
const expr = isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
return !isStringOrNumericLiteralLike(expr) &&
!isSignedNumericLiteral(expr) &&
!isWellKnownSymbolSyntactically(expr);
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/utilitiesPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ namespace ts {
(isFunctionExpression(declaration) || isClassExpression(declaration) ? getAssignedName(declaration) : undefined);
}

function getAssignedName(node: Node): DeclarationName | undefined {
/*@internal*/
export function getAssignedName(node: Node): DeclarationName | undefined {
if (!node.parent) {
return undefined;
}
Expand Down
3 changes: 3 additions & 0 deletions src/harness/fourslashImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3440,6 +3440,9 @@ namespace FourSlash {
let text = "";
text += `${prefix}╭ name: ${callHierarchyItem.name}\n`;
text += `${prefix}├ kind: ${callHierarchyItem.kind}\n`;
if (callHierarchyItem.containerName) {
text += `${prefix}├ containerName: ${callHierarchyItem.containerName}\n`;
}
text += `${prefix}├ file: ${callHierarchyItem.file}\n`;
text += `${prefix}├ span:\n`;
text += this.formatCallHierarchyItemSpan(file, callHierarchyItem.span, `${prefix}│ `);
Expand Down
2 changes: 1 addition & 1 deletion src/harness/harnessUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ namespace Utils {
case "symbolCount":
case "identifierCount":
case "scriptSnapshot":
// Blockist of items we never put in the baseline file.
// Blocklist of items we never put in the baseline file.
break;

case "originalKeywordKind":
Expand Down

0 comments on commit 09801d4

Please sign in to comment.