Skip to content

Commit ce23093

Browse files
2 parents 3fa111e + a2b4029 commit ce23093

File tree

312 files changed

+4285
-1054
lines changed

Some content is hidden

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

312 files changed

+4285
-1054
lines changed

src/compiler/binder.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,7 @@ namespace ts {
25152515
break;
25162516

25172517
default:
2518-
Debug.fail(Debug.showSyntaxKind(thisContainer));
2518+
Debug.failBadSyntaxKind(thisContainer);
25192519
}
25202520
}
25212521

@@ -2581,7 +2581,7 @@ namespace ts {
25812581
// Fix up parent pointers since we're going to use these nodes before we bind into them
25822582
node.left.parent = node;
25832583
node.right.parent = node;
2584-
if (isIdentifier(lhs.expression) && container === file && isNameOfExportsOrModuleExportsAliasDeclaration(file, lhs.expression)) {
2584+
if (isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) {
25852585
// This can be an alias for the 'exports' or 'module.exports' names, e.g.
25862586
// var util = module.exports;
25872587
// util.property = function ...
@@ -2975,21 +2975,27 @@ namespace ts {
29752975
}
29762976

29772977
export function isExportsOrModuleExportsOrAlias(sourceFile: SourceFile, node: Expression): boolean {
2978-
return isExportsIdentifier(node) ||
2979-
isModuleExportsPropertyAccessExpression(node) ||
2980-
isIdentifier(node) && isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node);
2981-
}
2982-
2983-
function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile: SourceFile, node: Identifier): boolean {
2984-
const symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
2985-
return !!symbol && !!symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration) &&
2986-
!!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer);
2987-
}
2988-
2989-
function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile: SourceFile, node: Expression): boolean {
2990-
return isExportsOrModuleExportsOrAlias(sourceFile, node) ||
2991-
(isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && (
2992-
isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.left) || isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node.right)));
2978+
let i = 0;
2979+
const q = [node];
2980+
while (q.length && i < 100) {
2981+
i++;
2982+
node = q.shift()!;
2983+
if (isExportsIdentifier(node) || isModuleExportsPropertyAccessExpression(node)) {
2984+
return true;
2985+
}
2986+
else if (isIdentifier(node)) {
2987+
const symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
2988+
if (!!symbol && !!symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
2989+
const init = symbol.valueDeclaration.initializer;
2990+
q.push(init);
2991+
if (isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) {
2992+
q.push(init.left);
2993+
q.push(init.right);
2994+
}
2995+
}
2996+
}
2997+
}
2998+
return false;
29932999
}
29943000

29953001
function lookupSymbolForNameWorker(container: Node, name: __String): Symbol | undefined {

src/compiler/checker.ts

Lines changed: 109 additions & 62 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,7 +2361,7 @@ namespace ts {
23612361
if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, Extension.Json)) {
23622362
extendedConfigPath = `${extendedConfigPath}.json`;
23632363
if (!host.fileExists(extendedConfigPath)) {
2364-
errors.push(createDiagnostic(Diagnostics.File_0_does_not_exist, extendedConfig));
2364+
errors.push(createDiagnostic(Diagnostics.File_0_not_found, extendedConfig));
23652365
return undefined;
23662366
}
23672367
}
@@ -2372,7 +2372,7 @@ namespace ts {
23722372
if (resolved.resolvedModule) {
23732373
return resolved.resolvedModule.resolvedFileName;
23742374
}
2375-
errors.push(createDiagnostic(Diagnostics.File_0_does_not_exist, extendedConfig));
2375+
errors.push(createDiagnostic(Diagnostics.File_0_not_found, extendedConfig));
23762376
return undefined;
23772377
}
23782378

src/compiler/core.ts

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,89 +1686,6 @@ namespace ts {
16861686
export type AnyFunction = (...args: never[]) => void;
16871687
export type AnyConstructor = new (...args: unknown[]) => unknown;
16881688

1689-
export namespace Debug {
1690-
export let currentAssertionLevel = AssertionLevel.None;
1691-
export let isDebugging = false;
1692-
1693-
export function shouldAssert(level: AssertionLevel): boolean {
1694-
return currentAssertionLevel >= level;
1695-
}
1696-
1697-
export function assert(expression: boolean, message?: string, verboseDebugInfo?: string | (() => string), stackCrawlMark?: AnyFunction): void {
1698-
if (!expression) {
1699-
if (verboseDebugInfo) {
1700-
message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
1701-
}
1702-
fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
1703-
}
1704-
}
1705-
1706-
export function assertEqual<T>(a: T, b: T, msg?: string, msg2?: string): void {
1707-
if (a !== b) {
1708-
const message = msg ? msg2 ? `${msg} ${msg2}` : msg : "";
1709-
fail(`Expected ${a} === ${b}. ${message}`);
1710-
}
1711-
}
1712-
1713-
export function assertLessThan(a: number, b: number, msg?: string): void {
1714-
if (a >= b) {
1715-
fail(`Expected ${a} < ${b}. ${msg || ""}`);
1716-
}
1717-
}
1718-
1719-
export function assertLessThanOrEqual(a: number, b: number): void {
1720-
if (a > b) {
1721-
fail(`Expected ${a} <= ${b}`);
1722-
}
1723-
}
1724-
1725-
export function assertGreaterThanOrEqual(a: number, b: number): void {
1726-
if (a < b) {
1727-
fail(`Expected ${a} >= ${b}`);
1728-
}
1729-
}
1730-
1731-
export function fail(message?: string, stackCrawlMark?: AnyFunction): never {
1732-
debugger;
1733-
const e = new Error(message ? `Debug Failure. ${message}` : "Debug Failure.");
1734-
if ((<any>Error).captureStackTrace) {
1735-
(<any>Error).captureStackTrace(e, stackCrawlMark || fail);
1736-
}
1737-
throw e;
1738-
}
1739-
1740-
export function assertDefined<T>(value: T | null | undefined, message?: string): T {
1741-
if (value === undefined || value === null) return fail(message);
1742-
return value;
1743-
}
1744-
1745-
export function assertEachDefined<T, A extends ReadonlyArray<T>>(value: A, message?: string): A {
1746-
for (const v of value) {
1747-
assertDefined(v, message);
1748-
}
1749-
return value;
1750-
}
1751-
1752-
export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never {
1753-
const detail = typeof member === "object" && "kind" in member && "pos" in member ? "SyntaxKind: " + showSyntaxKind(member as Node) : JSON.stringify(member);
1754-
return fail(`${message} ${detail}`, stackCrawlMark || assertNever);
1755-
}
1756-
1757-
export function getFunctionName(func: AnyFunction) {
1758-
if (typeof func !== "function") {
1759-
return "";
1760-
}
1761-
else if (func.hasOwnProperty("name")) {
1762-
return (<any>func).name;
1763-
}
1764-
else {
1765-
const text = Function.prototype.toString.call(func);
1766-
const match = /^function\s+([\w\$]+)\s*\(/.exec(text);
1767-
return match ? match[1] : "";
1768-
}
1769-
}
1770-
}
1771-
17721689
export function equateValues<T>(a: T, b: T) {
17731690
return a === b;
17741691
}

0 commit comments

Comments
 (0)