Skip to content

Commit a292ae1

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint
2 parents a37d34a + 3c690f1 commit a292ae1

File tree

106 files changed

+7500
-807
lines changed

Some content is hidden

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

106 files changed

+7500
-807
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
const MAX_UNICODE_CODEPOINT = 0x10FFFF;
3+
const isStart = c => /[\p{ID_Start}\u{2118}\u{212E}\u{309B}\u{309C}]/u.test(c); // Other_ID_Start explicitly included for back compat - see http://www.unicode.org/reports/tr31/#Introduction
4+
const isPart = c => /[\p{ID_Continue}\u{00B7}\u{0387}\u{19DA}\u{1369}\u{136A}\u{136B}\u{136C}\u{136D}\u{136E}\u{136F}\u{1370}\u{1371}]/u.test(c) || isStart(c); // Likewise for Other_ID_Continue
5+
const parts = [];
6+
let partsActive = false;
7+
let startsActive = false;
8+
const starts = [];
9+
10+
for (let i = 0; i < MAX_UNICODE_CODEPOINT; i++) {
11+
if (isStart(String.fromCodePoint(i)) !== startsActive) {
12+
starts.push(i - +startsActive);
13+
startsActive = !startsActive;
14+
}
15+
if (isPart(String.fromCodePoint(i)) !== partsActive) {
16+
parts.push(i - +partsActive);
17+
partsActive = !partsActive;
18+
}
19+
}
20+
21+
console.log(`/**
22+
* Generated by scripts/regenerate-unicode-identifier-parts.js on node ${process.version} with unicode ${process.versions.unicode}
23+
* based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords
24+
* unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and
25+
* unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start
26+
*/`);
27+
console.log(`const unicodeESNextIdentifierStart = [${starts.join(", ")}];`);
28+
console.log(`const unicodeESNextIdentifierPart = [${parts.join(", ")}];`);

src/compiler/binder.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,11 @@ namespace ts {
490490
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
491491
if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
492492
if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypeAlias(node)) {
493-
if (hasModifier(node, ModifierFlags.Default) && !getDeclarationName(node)) {
493+
if (!container.locals || (hasModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
494494
return declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
495495
}
496496
const exportKind = symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0;
497-
const local = declareSymbol(container.locals!, /*parent*/ undefined, node, exportKind, symbolExcludes);
497+
const local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes);
498498
local.exportSymbol = declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes);
499499
node.localSymbol = local;
500500
return local;
@@ -1806,7 +1806,19 @@ namespace ts {
18061806
currentFlow = { flags: FlowFlags.Start };
18071807
parent = typeAlias;
18081808
bind(typeAlias.typeExpression);
1809-
if (isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === SyntaxKind.Identifier) {
1809+
const declName = getNameOfDeclaration(typeAlias);
1810+
if ((isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && isPropertyAccessEntityNameExpression(declName.parent)) {
1811+
// typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C
1812+
const isTopLevel = isTopLevelNamespaceAssignment(declName.parent);
1813+
if (isTopLevel) {
1814+
bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!findAncestor(declName, d => isPropertyAccessExpression(d) && d.name.escapedText === "prototype"));
1815+
const oldContainer = container;
1816+
container = isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression;
1817+
declareModuleMember(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
1818+
container = oldContainer;
1819+
}
1820+
}
1821+
else if (isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === SyntaxKind.Identifier) {
18101822
parent = typeAlias.parent;
18111823
bindBlockScopedDeclaration(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
18121824
}
@@ -2607,7 +2619,7 @@ namespace ts {
26072619
}
26082620

26092621
function bindPotentiallyMissingNamespaces(namespaceSymbol: Symbol | undefined, entityName: EntityNameExpression, isToplevel: boolean, isPrototypeProperty: boolean) {
2610-
if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & SymbolFlags.Namespace))) {
2622+
if (isToplevel && !isPrototypeProperty) {
26112623
// make symbols or add declarations for intermediate containers
26122624
const flags = SymbolFlags.Module | SymbolFlags.Assignment;
26132625
const excludeFlags = SymbolFlags.ValueModuleExcludes & ~SymbolFlags.Assignment;
@@ -2642,11 +2654,15 @@ namespace ts {
26422654
declareSymbol(symbolTable, namespaceSymbol, declaration, includes | SymbolFlags.Assignment, excludes & ~SymbolFlags.Assignment);
26432655
}
26442656

2645-
function bindPropertyAssignment(name: EntityNameExpression, propertyAccess: PropertyAccessEntityNameExpression, isPrototypeProperty: boolean) {
2646-
let namespaceSymbol = lookupSymbolForPropertyAccess(name);
2647-
const isToplevel = isBinaryExpression(propertyAccess.parent)
2657+
function isTopLevelNamespaceAssignment(propertyAccess: PropertyAccessEntityNameExpression) {
2658+
return isBinaryExpression(propertyAccess.parent)
26482659
? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === SyntaxKind.SourceFile
26492660
: propertyAccess.parent.parent.kind === SyntaxKind.SourceFile;
2661+
}
2662+
2663+
function bindPropertyAssignment(name: EntityNameExpression, propertyAccess: PropertyAccessEntityNameExpression, isPrototypeProperty: boolean) {
2664+
let namespaceSymbol = lookupSymbolForPropertyAccess(name);
2665+
const isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
26502666
namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty);
26512667
bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
26522668
}

0 commit comments

Comments
 (0)