From c43a36adfdb092bf96f1c72ceeeb26e598f17411 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:46:07 -0700 Subject: [PATCH 1/3] Switch to module and make lint rule --- eslint.config.mjs | 7 + scripts/eslint/rules/no-direct-import.cjs | 3 + scripts/eslint/rules/prefer-direct-import.cjs | 124 ++ scripts/eslint/tests/prefer-direct-import.cjs | 79 + src/compiler/_namespaces/ts.ts | 3 +- src/compiler/debug.ts | 1958 +++++++++-------- src/compiler/factory/utilities.ts | 3 +- src/compiler/moduleSpecifiers.ts | 2 +- src/compiler/parser.ts | 5 +- src/compiler/sys.ts | 7 +- .../transformers/declarations/diagnostics.ts | 2 +- src/compiler/utilities.ts | 8 +- src/server/editorServices.ts | 3 +- src/testRunner/runner.ts | 4 +- src/testRunner/unittests/debugDeprecation.ts | 28 +- src/tsc/tsc.ts | 4 +- src/tsserver/nodeServer.ts | 12 +- src/typescript/typescript.ts | 17 +- 18 files changed, 1266 insertions(+), 1003 deletions(-) create mode 100644 scripts/eslint/rules/prefer-direct-import.cjs create mode 100644 scripts/eslint/tests/prefer-direct-import.cjs diff --git a/eslint.config.mjs b/eslint.config.mjs index bc30b791311be..9e943fbb97b73 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -157,6 +157,7 @@ export default tseslint.config( "local/jsdoc-format": "error", "local/js-extensions": "error", "local/no-array-mutating-method-expressions": "error", + "local/prefer-direct-import": "error", }, }, { @@ -222,6 +223,12 @@ export default tseslint.config( "local/no-direct-import": "off", }, }, + { + files: ["src/harness/**", "src/testRunner/**", "src/tsserver/**", "src/typingsInstaller/**"], + rules: { + "local/prefer-direct-import": "off", + }, + }, { files: ["src/lib/*.d.ts"], ...tseslint.configs.disableTypeChecked, diff --git a/scripts/eslint/rules/no-direct-import.cjs b/scripts/eslint/rules/no-direct-import.cjs index 614e67db30be3..2d407fd0b5507 100644 --- a/scripts/eslint/rules/no-direct-import.cjs +++ b/scripts/eslint/rules/no-direct-import.cjs @@ -45,6 +45,9 @@ module.exports = createRule({ // These appear in place of public API imports. if (p.endsWith("../typescript/typescript.js")) return; + // Okay to direct import, for now. + // TODO(jakebailey): we should consider where this is safe to ignore + if (p.endsWith("/debug.js")) return; // The below is similar to https://github.com/microsoft/DefinitelyTyped-tools/blob/main/packages/eslint-plugin/src/rules/no-bad-reference.ts diff --git a/scripts/eslint/rules/prefer-direct-import.cjs b/scripts/eslint/rules/prefer-direct-import.cjs new file mode 100644 index 0000000000000..ef57906c8cf83 --- /dev/null +++ b/scripts/eslint/rules/prefer-direct-import.cjs @@ -0,0 +1,124 @@ +const { AST_NODE_TYPES } = require("@typescript-eslint/utils"); +const { createRule } = require("./utils.cjs"); +const path = require("path"); + +const srcRoot = path.resolve(__dirname, "../../../src"); + +const tsNamespaceBarrelRegex = /_namespaces\/ts(?:\.ts|\.js|\.mts|\.mjs|\.cts|\.cjs)?$/; + +/** + * @type {Array<{ name: string; path: string; }>} + */ +const modules = [ + { + name: "Debug", + path: "compiler/debug", + }, +]; + +module.exports = createRule({ + name: "prefer-direct-import", + meta: { + docs: { + description: ``, + }, + messages: { + importError: `{{ name }} should be imported directly from {{ path }}`, + }, + schema: [], + type: "problem", + fixable: "code", + }, + defaultOptions: [], + + create(context) { + /** + * @param {string} p + */ + function getImportPath(p) { + let out = path.relative(path.dirname(context.filename), path.join(srcRoot, p)).replace(/\\/g, "/"); + if (!out.startsWith(".")) out = "./" + out; + return out; + } + + /** @type {any} */ + let program; + let addedImport = false; + + return { + Program: node => { + program = node; + }, + ImportDeclaration: node => { + if (node.importKind !== "value" || !tsNamespaceBarrelRegex.test(node.source.value)) return; + + for (const specifier of node.specifiers) { + if (specifier.type !== AST_NODE_TYPES.ImportSpecifier || specifier.importKind !== "value") continue; + + for (const mod of modules) { + if (specifier.imported.name !== mod.name) continue; + + context.report({ + messageId: "importError", + data: { name: mod.name, path: mod.path }, + node: specifier, + fix: fixer => { + const newCode = `import * as ${mod.name} from "${getImportPath(mod.path)}";`; + const fixes = []; + if (node.specifiers.length === 1) { + if (addedImport) { + fixes.push(fixer.remove(node)); + } + else { + fixes.push(fixer.replaceText(node, newCode)); + addedImport = true; + } + } + else { + const comma = context.sourceCode.getTokenAfter(specifier, token => token.value === ","); + if (!comma) throw new Error("comma is null"); + const prevNode = context.sourceCode.getTokenBefore(specifier); + if (!prevNode) throw new Error("prevNode is null"); + fixes.push( + fixer.removeRange([prevNode.range[1], specifier.range[0]]), + fixer.remove(specifier), + fixer.remove(comma), + ); + if (!addedImport) { + fixes.push(fixer.insertTextBefore(node, newCode + "\r\n")); + addedImport = true; + } + } + + return fixes; + }, + }); + } + } + }, + MemberExpression: node => { + if (node.object.type !== AST_NODE_TYPES.Identifier || node.object.name !== "ts") return; + + for (const mod of modules) { + if (node.property.type !== AST_NODE_TYPES.Identifier || node.property.name !== mod.name) continue; + + context.report({ + messageId: "importError", + data: { name: mod.name, path: mod.path }, + node, + fix: fixer => { + const fixes = [fixer.replaceText(node, mod.name)]; + + if (!addedImport) { + fixes.push(fixer.insertTextBefore(program, `import * as ${mod.name} from "${getImportPath(mod.path)}";\r\n`)); + addedImport = true; + } + + return fixes; + }, + }); + } + }, + }; + }, +}); diff --git a/scripts/eslint/tests/prefer-direct-import.cjs b/scripts/eslint/tests/prefer-direct-import.cjs new file mode 100644 index 0000000000000..e451d0c195de8 --- /dev/null +++ b/scripts/eslint/tests/prefer-direct-import.cjs @@ -0,0 +1,79 @@ +const { RuleTester } = require("./support/RuleTester.cjs"); +const rule = require("../rules/prefer-direct-import.cjs"); + +const ruleTester = new RuleTester({ + languageOptions: { + parserOptions: { + warnOnUnsupportedTypeScriptVersion: false, + }, + }, +}); + +ruleTester.run("no-ts-debug", rule, { + valid: [ + { + code: ` +import * as Debug from "./debug"; + `, + }, + { + code: ` +import type { Debug } from "./_namespaces/ts"; + `, + }, + { + code: ` +import { type Debug } from "./_namespaces/ts"; + `, + }, + ], + + invalid: [ + { + filename: "src/compiler/checker.ts", + code: ` +import { Debug } from "./_namespaces/ts"; + `.replace(/\r?\n/g, "\r\n"), + errors: [{ messageId: "importError", data: { name: "Debug", path: "compiler/debug" } }], + output: ` +import * as Debug from "./debug"; + `.replace(/\r?\n/g, "\r\n"), + }, + { + filename: "src/compiler/transformers/ts.ts", + code: ` +import { Debug } from "../_namespaces/ts"; + `.replace(/\r?\n/g, "\r\n"), + errors: [{ messageId: "importError", data: { name: "Debug", path: "compiler/debug" } }], + output: ` +import * as Debug from "../debug"; + `.replace(/\r?\n/g, "\r\n"), + }, + // TODO(jakebailey): the rule probably needs to handle .js extensions + { + filename: "src/compiler/checker.ts", + code: ` +import { Debug } from "./_namespaces/ts.js"; + `.replace(/\r?\n/g, "\r\n"), + errors: [{ messageId: "importError", data: { name: "Debug", path: "compiler/debug" } }], + output: ` +import * as Debug from "./debug"; + `.replace(/\r?\n/g, "\r\n"), + }, + { + filename: "src/compiler/checker.ts", + code: ` +import * as ts from "./_namespaces/ts"; + +ts.Debug.assert(true); + `.replace(/\r?\n/g, "\r\n"), + errors: [{ messageId: "importError", data: { name: "Debug", path: "compiler/debug" } }], + output: ` +import * as Debug from "./debug"; +import * as ts from "./_namespaces/ts"; + +Debug.assert(true); + `.replace(/\r?\n/g, "\r\n"), + }, + ], +}); diff --git a/src/compiler/_namespaces/ts.ts b/src/compiler/_namespaces/ts.ts index 94fb16857d38e..013e89ef6a3a0 100644 --- a/src/compiler/_namespaces/ts.ts +++ b/src/compiler/_namespaces/ts.ts @@ -2,7 +2,8 @@ export * from "../corePublic.js"; export * from "../core.js"; -export * from "../debug.js"; +import * as Debug from "../debug.js"; +export { Debug }; export * from "../semver.js"; export * from "../performanceCore.js"; export * from "../tracing.js"; diff --git a/src/compiler/debug.ts b/src/compiler/debug.ts index 42e8637ac178a..f4960e1ded7ff 100644 --- a/src/compiler/debug.ts +++ b/src/compiler/debug.ts @@ -1,7 +1,6 @@ import * as ts from "./_namespaces/ts.js"; import { AnyFunction, - AssertionLevel, BigIntLiteralType, CheckMode, compareValues, @@ -13,7 +12,6 @@ import { FlowSwitchClause, getEffectiveModifierFlagsNoCache, getEmitFlags, - getOwnKeys, getParseTreeNode, getSourceFileOfNode, getSourceTextOfNodeFromSourceFile, @@ -60,7 +58,6 @@ import { isUnionTypeNode, LiteralType, map, - MatchingKeys, maxBy, ModifierFlags, Node, @@ -68,7 +65,6 @@ import { NodeCheckFlags, NodeFlags, nodeIsSynthesized, - noop, objectAllocator, ObjectFlags, ObjectType, @@ -110,1145 +106,1205 @@ export interface LoggingHost { } /** @internal */ -export namespace Debug { - /* eslint-disable prefer-const */ - let currentAssertionLevel = AssertionLevel.None; - export let currentLogLevel: LogLevel = LogLevel.Warning; - export let isDebugging = false; - export let loggingHost: LoggingHost | undefined; - /* eslint-enable prefer-const */ +export const enum AssertionLevel { + None = 0, + Normal = 1, + Aggressive = 2, + VeryAggressive = 3, +} - type AssertionKeys = MatchingKeys; +let currentAssertionLevel = AssertionLevel.None; - export function shouldLog(level: LogLevel): boolean { - return currentLogLevel <= level; - } +/** @internal */ +export let currentLogLevel: LogLevel = LogLevel.Warning; - function logMessage(level: LogLevel, s: string): void { - if (loggingHost && shouldLog(level)) { - loggingHost.log(level, s); - } - } +/** @internal */ +export function setCurrentLogLevel(newCurrentLogLevel: LogLevel): void { + currentLogLevel = newCurrentLogLevel; +} - export function log(s: string): void { - logMessage(LogLevel.Info, s); - } +/** @internal */ +export let isDebugging = false; - export namespace log { - export function error(s: string): void { - logMessage(LogLevel.Error, s); - } +/** @internal */ +export function setIsDebugging(newIsDebugging: boolean): void { + isDebugging = newIsDebugging; +} - export function warn(s: string): void { - logMessage(LogLevel.Warning, s); - } +/** @internal */ +export let loggingHost: LoggingHost | undefined; - export function log(s: string): void { - logMessage(LogLevel.Info, s); - } +/** @internal */ +export function setLoggingHost(newLoggingHost: LoggingHost | undefined): void { + loggingHost = newLoggingHost; +} - export function trace(s: string): void { - logMessage(LogLevel.Verbose, s); - } +/** @internal */ +export function shouldLog(level: LogLevel): boolean { + return currentLogLevel <= level; +} + +function logMessage(level: LogLevel, s: string): void { + if (loggingHost && shouldLog(level)) { + loggingHost.log(level, s); } +} - const assertionCache: Partial> = {}; +/** @internal */ +export function log(s: string): void { + logMessage(LogLevel.Info, s); +} - export function getAssertionLevel(): AssertionLevel { - return currentAssertionLevel; +/** @internal */ +export namespace log { + export function error(s: string): void { + logMessage(LogLevel.Error, s); } - export function setAssertionLevel(level: AssertionLevel): void { - const prevAssertionLevel = currentAssertionLevel; - currentAssertionLevel = level; - - if (level > prevAssertionLevel) { - // restore assertion functions for the current assertion level (see `shouldAssertFunction`). - for (const key of getOwnKeys(assertionCache) as AssertionKeys[]) { - const cachedFunc = assertionCache[key]; - if (cachedFunc !== undefined && Debug[key] !== cachedFunc.assertion && level >= cachedFunc.level) { - (Debug as any)[key] = cachedFunc; - assertionCache[key] = undefined; - } - } - } + export function warn(s: string): void { + logMessage(LogLevel.Warning, s); } - export function shouldAssert(level: AssertionLevel): boolean { - return currentAssertionLevel >= level; + export function log(s: string): void { + logMessage(LogLevel.Info, s); } - /** - * Tests whether an assertion function should be executed. If it shouldn't, it is cached and replaced with `ts.noop`. - * Replaced assertion functions are restored when `Debug.setAssertionLevel` is set to a high enough level. - * @param level The minimum assertion level required. - * @param name The name of the current assertion function. - */ - function shouldAssertFunction(level: AssertionLevel, name: K): boolean { - if (!shouldAssert(level)) { - assertionCache[name] = { level, assertion: Debug[name] }; - (Debug as any)[name] = noop; - return false; - } - return true; + export function trace(s: string): void { + logMessage(LogLevel.Verbose, s); } +} - export function fail(message?: string, stackCrawlMark?: AnyFunction): never { - // eslint-disable-next-line no-debugger - debugger; - const e = new Error(message ? `Debug Failure. ${message}` : "Debug Failure."); - if ((Error as any).captureStackTrace) { - (Error as any).captureStackTrace(e, stackCrawlMark || fail); - } - throw e; - } +/** @internal */ +export function getAssertionLevel(): AssertionLevel { + return currentAssertionLevel; +} - export function failBadSyntaxKind(node: Node, message?: string, stackCrawlMark?: AnyFunction): never { - return fail( - `${message || "Unexpected node."}\r\nNode ${formatSyntaxKind(node.kind)} was unexpected.`, - stackCrawlMark || failBadSyntaxKind, - ); - } +/** @internal */ +export function setAssertionLevel(level: AssertionLevel): void { + currentAssertionLevel = level; +} - export function assert(expression: unknown, message?: string, verboseDebugInfo?: string | (() => string), stackCrawlMark?: AnyFunction): asserts expression { - if (!expression) { - message = message ? `False expression: ${message}` : "False expression."; - if (verboseDebugInfo) { - message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); - } - fail(message, stackCrawlMark || assert); - } - } +/** @internal */ +export function shouldAssert(level: AssertionLevel): boolean { + return currentAssertionLevel >= level; +} - export function assertEqual(a: T, b: T, msg?: string, msg2?: string, stackCrawlMark?: AnyFunction): void { - if (a !== b) { - const message = msg ? msg2 ? `${msg} ${msg2}` : msg : ""; - fail(`Expected ${a} === ${b}. ${message}`, stackCrawlMark || assertEqual); - } +/** @internal */ +export function fail(message?: string, stackCrawlMark?: AnyFunction): never { + // eslint-disable-next-line no-debugger + debugger; + const e = new Error(message ? `Debug Failure. ${message}` : "Debug Failure."); + if ((Error as any).captureStackTrace) { + (Error as any).captureStackTrace(e, stackCrawlMark || fail); } + throw e; +} - export function assertLessThan(a: number, b: number, msg?: string, stackCrawlMark?: AnyFunction): void { - if (a >= b) { - fail(`Expected ${a} < ${b}. ${msg || ""}`, stackCrawlMark || assertLessThan); - } - } +/** @internal */ +export function failBadSyntaxKind(node: Node, message?: string, stackCrawlMark?: AnyFunction): never { + return fail( + `${message || "Unexpected node."}\r\nNode ${formatSyntaxKind(node.kind)} was unexpected.`, + stackCrawlMark || failBadSyntaxKind, + ); +} - export function assertLessThanOrEqual(a: number, b: number, stackCrawlMark?: AnyFunction): void { - if (a > b) { - fail(`Expected ${a} <= ${b}`, stackCrawlMark || assertLessThanOrEqual); +/** @internal */ +export function assert(expression: unknown, message?: string, verboseDebugInfo?: string | (() => string), stackCrawlMark?: AnyFunction): asserts expression { + if (!expression) { + message = message ? `False expression: ${message}` : "False expression."; + if (verboseDebugInfo) { + message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } + fail(message, stackCrawlMark || assert); } +} - export function assertGreaterThanOrEqual(a: number, b: number, stackCrawlMark?: AnyFunction): void { - if (a < b) { - fail(`Expected ${a} >= ${b}`, stackCrawlMark || assertGreaterThanOrEqual); - } +/** @internal */ +export function assertEqual(a: T, b: T, msg?: string, msg2?: string, stackCrawlMark?: AnyFunction): void { + if (a !== b) { + const message = msg ? msg2 ? `${msg} ${msg2}` : msg : ""; + fail(`Expected ${a} === ${b}. ${message}`, stackCrawlMark || assertEqual); } +} - export function assertIsDefined(value: T, message?: string, stackCrawlMark?: AnyFunction): asserts value is NonNullable { - // eslint-disable-next-line no-restricted-syntax - if (value === undefined || value === null) { - fail(message, stackCrawlMark || assertIsDefined); - } +/** @internal */ +export function assertLessThan(a: number, b: number, msg?: string, stackCrawlMark?: AnyFunction): void { + if (a >= b) { + fail(`Expected ${a} < ${b}. ${msg || ""}`, stackCrawlMark || assertLessThan); } +} - export function checkDefined(value: T | null | undefined, message?: string, stackCrawlMark?: AnyFunction): T { // eslint-disable-line no-restricted-syntax - assertIsDefined(value, message, stackCrawlMark || checkDefined); - return value; +/** @internal */ +export function assertLessThanOrEqual(a: number, b: number, stackCrawlMark?: AnyFunction): void { + if (a > b) { + fail(`Expected ${a} <= ${b}`, stackCrawlMark || assertLessThanOrEqual); } +} - export function assertEachIsDefined(value: NodeArray, message?: string, stackCrawlMark?: AnyFunction): asserts value is NodeArray; - export function assertEachIsDefined(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction): asserts value is readonly NonNullable[]; - export function assertEachIsDefined(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction) { - for (const v of value) { - assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined); - } +/** @internal */ +export function assertGreaterThanOrEqual(a: number, b: number, stackCrawlMark?: AnyFunction): void { + if (a < b) { + fail(`Expected ${a} >= ${b}`, stackCrawlMark || assertGreaterThanOrEqual); } +} - export function checkEachDefined(value: A, message?: string, stackCrawlMark?: AnyFunction): A { - assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined); - return value; +/** @internal */ +export function assertIsDefined(value: T, message?: string, stackCrawlMark?: AnyFunction): asserts value is NonNullable { + // eslint-disable-next-line no-restricted-syntax + if (value === undefined || value === null) { + fail(message, stackCrawlMark || assertIsDefined); } +} - export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never { - const detail = typeof member === "object" && hasProperty(member, "kind") && hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind((member as Node).kind) : JSON.stringify(member); - return fail(`${message} ${detail}`, stackCrawlMark || assertNever); - } +/** @internal */ +export function checkDefined(value: T | null | undefined, message?: string, stackCrawlMark?: AnyFunction): T { // eslint-disable-line no-restricted-syntax + assertIsDefined(value, message, stackCrawlMark || checkDefined); + return value; +} - export function assertEachNode(nodes: NodeArray, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray; - export function assertEachNode(nodes: readonly T[], test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[]; - export function assertEachNode(nodes: NodeArray | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray | undefined; - export function assertEachNode(nodes: readonly T[] | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[] | undefined; - export function assertEachNode(nodes: readonly Node[], test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; - export function assertEachNode(nodes: readonly Node[] | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { - if (shouldAssertFunction(AssertionLevel.Normal, "assertEachNode")) { - assert( - test === undefined || every(nodes, test), - message || "Unexpected node.", - () => `Node array did not pass test '${getFunctionName(test!)}'.`, - stackCrawlMark || assertEachNode, - ); - } +/** @internal */ +export function assertEachIsDefined(value: NodeArray, message?: string, stackCrawlMark?: AnyFunction): asserts value is NodeArray; +/** @internal */ +export function assertEachIsDefined(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction): asserts value is readonly NonNullable[]; +export function assertEachIsDefined(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction) { + for (const v of value) { + assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined); } +} - export function assertNode(node: T | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U; - export function assertNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; - export function assertNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { - if (shouldAssertFunction(AssertionLevel.Normal, "assertNode")) { - assert( - node !== undefined && (test === undefined || test(node)), - message || "Unexpected node.", - () => `Node ${formatSyntaxKind(node?.kind)} did not pass test '${getFunctionName(test!)}'.`, - stackCrawlMark || assertNode, - ); - } +/** @internal */ +export function checkEachDefined(value: A, message?: string, stackCrawlMark?: AnyFunction): A { + assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined); + return value; +} + +/** @internal */ +export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never { + const detail = typeof member === "object" && hasProperty(member, "kind") && hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind((member as Node).kind) : JSON.stringify(member); + return fail(`${message} ${detail}`, stackCrawlMark || assertNever); +} + +/** @internal */ +export function assertEachNode(nodes: NodeArray, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray; +/** @internal */ +export function assertEachNode(nodes: readonly T[], test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[]; +/** @internal */ +export function assertEachNode(nodes: NodeArray | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray | undefined; +/** @internal */ +export function assertEachNode(nodes: readonly T[] | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[] | undefined; +/** @internal */ +export function assertEachNode(nodes: readonly Node[], test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; +export function assertEachNode(nodes: readonly Node[] | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssert(AssertionLevel.Normal)) { + assert( + test === undefined || every(nodes, test), + message || "Unexpected node.", + () => `Node array did not pass test '${getFunctionName(test!)}'.`, + stackCrawlMark || assertEachNode, + ); } +} - export function assertNotNode(node: T | undefined, test: (node: Node) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is Exclude; - export function assertNotNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; - export function assertNotNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { - if (shouldAssertFunction(AssertionLevel.Normal, "assertNotNode")) { - assert( - node === undefined || test === undefined || !test(node), - message || "Unexpected node.", - () => `Node ${formatSyntaxKind(node!.kind)} should not have passed test '${getFunctionName(test!)}'.`, - stackCrawlMark || assertNotNode, - ); - } +/** @internal */ +export function assertNode(node: T | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U; +/** @internal */ +export function assertNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; +export function assertNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssert(AssertionLevel.Normal)) { + assert( + node !== undefined && (test === undefined || test(node)), + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node?.kind)} did not pass test '${getFunctionName(test!)}'.`, + stackCrawlMark || assertNode, + ); } +} - export function assertOptionalNode(node: T, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U; - export function assertOptionalNode(node: T | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U | undefined; - export function assertOptionalNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; - export function assertOptionalNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { - if (shouldAssertFunction(AssertionLevel.Normal, "assertOptionalNode")) { - assert( - test === undefined || node === undefined || test(node), - message || "Unexpected node.", - () => `Node ${formatSyntaxKind(node?.kind)} did not pass test '${getFunctionName(test!)}'.`, - stackCrawlMark || assertOptionalNode, - ); - } +/** @internal */ +export function assertNotNode(node: T | undefined, test: (node: Node) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is Exclude; +/** @internal */ +export function assertNotNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; +export function assertNotNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssert(AssertionLevel.Normal)) { + assert( + node === undefined || test === undefined || !test(node), + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node!.kind)} should not have passed test '${getFunctionName(test!)}'.`, + stackCrawlMark || assertNotNode, + ); } +} - export function assertOptionalToken(node: T, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract; - export function assertOptionalToken(node: T | undefined, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract | undefined; - export function assertOptionalToken(node: Node | undefined, kind: SyntaxKind | undefined, message?: string, stackCrawlMark?: AnyFunction): void; - export function assertOptionalToken(node: Node | undefined, kind: SyntaxKind | undefined, message?: string, stackCrawlMark?: AnyFunction) { - if (shouldAssertFunction(AssertionLevel.Normal, "assertOptionalToken")) { - assert( - kind === undefined || node === undefined || node.kind === kind, - message || "Unexpected node.", - () => `Node ${formatSyntaxKind(node?.kind)} was not a '${formatSyntaxKind(kind)}' token.`, - stackCrawlMark || assertOptionalToken, - ); - } +/** @internal */ +export function assertOptionalNode(node: T, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U; +/** @internal */ +export function assertOptionalNode(node: T | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts node is U | undefined; +/** @internal */ +export function assertOptionalNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void; +export function assertOptionalNode(node: Node | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssert(AssertionLevel.Normal)) { + assert( + test === undefined || node === undefined || test(node), + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node?.kind)} did not pass test '${getFunctionName(test!)}'.`, + stackCrawlMark || assertOptionalNode, + ); } +} - export function assertMissingNode(node: Node | undefined, message?: string, stackCrawlMark?: AnyFunction): asserts node is undefined; - export function assertMissingNode(node: Node | undefined, message?: string, stackCrawlMark?: AnyFunction) { - if (shouldAssertFunction(AssertionLevel.Normal, "assertMissingNode")) { - assert( - node === undefined, - message || "Unexpected node.", - () => `Node ${formatSyntaxKind(node!.kind)} was unexpected'.`, - stackCrawlMark || assertMissingNode, - ); - } +/** @internal */ +export function assertOptionalToken(node: T, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract; +/** @internal */ +export function assertOptionalToken(node: T | undefined, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract | undefined; +/** @internal */ +export function assertOptionalToken(node: Node | undefined, kind: SyntaxKind | undefined, message?: string, stackCrawlMark?: AnyFunction): void; +export function assertOptionalToken(node: Node | undefined, kind: SyntaxKind | undefined, message?: string, stackCrawlMark?: AnyFunction) { + if (shouldAssert(AssertionLevel.Normal)) { + assert( + kind === undefined || node === undefined || node.kind === kind, + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node?.kind)} was not a '${formatSyntaxKind(kind)}' token.`, + stackCrawlMark || assertOptionalToken, + ); } +} - /** - * Asserts a value has the specified type in typespace only (does not perform a runtime assertion). - * This is useful in cases where we switch on `node.kind` and can be reasonably sure the type is accurate, and - * as a result can reduce the number of unnecessary casts. - */ - export function type(value: unknown): asserts value is T; - export function type(_value: unknown) {} - - export function getFunctionName(func: AnyFunction): string { - if (typeof func !== "function") { - return ""; - } - else if (hasProperty(func, "name")) { - return (func as any).name; - } - else { - const text = Function.prototype.toString.call(func); - const match = /^function\s+([\w$]+)\s*\(/.exec(text); - return match ? match[1] : ""; - } +/** @internal */ +export function assertMissingNode(node: Node | undefined, message?: string, stackCrawlMark?: AnyFunction): void { + if (shouldAssert(AssertionLevel.Normal)) { + assert( + node === undefined, + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node!.kind)} was unexpected'.`, + stackCrawlMark || assertMissingNode, + ); } +} + +/** + * Asserts a value has the specified type in typespace only (does not perform a runtime assertion). + * This is useful in cases where we switch on `node.kind` and can be reasonably sure the type is accurate, and + * as a result can reduce the number of unnecessary casts. + * + * @internal + */ +export function assertType(value: unknown): asserts value is T; +export function assertType(_value: unknown) {} - export function formatSymbol(symbol: Symbol): string { - return `{ name: ${unescapeLeadingUnderscores(symbol.escapedName)}; flags: ${formatSymbolFlags(symbol.flags)}; declarations: ${map(symbol.declarations, node => formatSyntaxKind(node.kind))} }`; +/** @internal */ +export function getFunctionName(func: AnyFunction): string { + if (typeof func !== "function") { + return ""; + } + else if (hasProperty(func, "name")) { + return (func as any).name; + } + else { + const text = Function.prototype.toString.call(func); + const match = /^function\s+([\w$]+)\s*\(/.exec(text); + return match ? match[1] : ""; } +} - /** - * Formats an enum value as a string for debugging and debug assertions. - */ - export function formatEnum(value = 0, enumObject: any, isFlags?: boolean): string { - const members = getEnumMembers(enumObject); - if (value === 0) { - return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0"; - } - if (isFlags) { - const result: string[] = []; - let remainingFlags = value; - for (const [enumValue, enumName] of members) { - if (enumValue > value) { - break; - } - if (enumValue !== 0 && enumValue & value) { - result.push(enumName); - remainingFlags &= ~enumValue; - } +/** @internal */ +export function formatSymbol(symbol: Symbol): string { + return `{ name: ${unescapeLeadingUnderscores(symbol.escapedName)}; flags: ${formatSymbolFlags(symbol.flags)}; declarations: ${map(symbol.declarations, node => formatSyntaxKind(node.kind))} }`; +} + +/** + * Formats an enum value as a string for debugging and debug assertions. + * + * @internal + */ +export function formatEnum(value = 0, enumObject: any, isFlags?: boolean): string { + const members = getEnumMembers(enumObject); + if (value === 0) { + return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0"; + } + if (isFlags) { + const result: string[] = []; + let remainingFlags = value; + for (const [enumValue, enumName] of members) { + if (enumValue > value) { + break; } - if (remainingFlags === 0) { - return result.join("|"); + if (enumValue !== 0 && enumValue & value) { + result.push(enumName); + remainingFlags &= ~enumValue; } } - else { - for (const [enumValue, enumName] of members) { - if (enumValue === value) { - return enumName; - } + if (remainingFlags === 0) { + return result.join("|"); + } + } + else { + for (const [enumValue, enumName] of members) { + if (enumValue === value) { + return enumName; } } - return value.toString(); } + return value.toString(); +} - const enumMemberCache = new Map>(); +const enumMemberCache = new Map>(); - function getEnumMembers(enumObject: any) { - // Assuming enum objects do not change at runtime, we can cache the enum members list - // to reuse later. This saves us from reconstructing this each and every time we call - // a formatting function (which can be expensive for large enums like SyntaxKind). - const existing = enumMemberCache.get(enumObject); - if (existing) { - return existing; - } +function getEnumMembers(enumObject: any) { + // Assuming enum objects do not change at runtime, we can cache the enum members list + // to reuse later. This saves us from reconstructing this each and every time we call + // a formatting function (which can be expensive for large enums like SyntaxKind). + const existing = enumMemberCache.get(enumObject); + if (existing) { + return existing; + } - const result: [number, string][] = []; - for (const name in enumObject) { - const value = enumObject[name]; - if (typeof value === "number") { - result.push([value, name]); - } + const result: [number, string][] = []; + for (const name in enumObject) { + const value = enumObject[name]; + if (typeof value === "number") { + result.push([value, name]); } - - const sorted = toSorted<[number, string]>(result, (x, y) => compareValues(x[0], y[0])); - enumMemberCache.set(enumObject, sorted); - return sorted; } - export function formatSyntaxKind(kind: SyntaxKind | undefined): string { - return formatEnum(kind, (ts as any).SyntaxKind, /*isFlags*/ false); - } + const sorted = toSorted<[number, string]>(result, (x, y) => compareValues(x[0], y[0])); + enumMemberCache.set(enumObject, sorted); + return sorted; +} - export function formatSnippetKind(kind: SnippetKind | undefined): string { - return formatEnum(kind, (ts as any).SnippetKind, /*isFlags*/ false); - } +/** @internal */ +export function formatSyntaxKind(kind: SyntaxKind | undefined): string { + return formatEnum(kind, (ts as any).SyntaxKind, /*isFlags*/ false); +} - export function formatScriptKind(kind: ScriptKind | undefined): string { - return formatEnum(kind, (ts as any).ScriptKind, /*isFlags*/ false); - } +/** @internal */ +export function formatSnippetKind(kind: SnippetKind | undefined): string { + return formatEnum(kind, (ts as any).SnippetKind, /*isFlags*/ false); +} - export function formatNodeFlags(flags: NodeFlags | undefined): string { - return formatEnum(flags, (ts as any).NodeFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatScriptKind(kind: ScriptKind | undefined): string { + return formatEnum(kind, (ts as any).ScriptKind, /*isFlags*/ false); +} - export function formatNodeCheckFlags(flags: NodeCheckFlags | undefined): string { - return formatEnum(flags, (ts as any).NodeCheckFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatNodeFlags(flags: NodeFlags | undefined): string { + return formatEnum(flags, (ts as any).NodeFlags, /*isFlags*/ true); +} - export function formatModifierFlags(flags: ModifierFlags | undefined): string { - return formatEnum(flags, (ts as any).ModifierFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatNodeCheckFlags(flags: NodeCheckFlags | undefined): string { + return formatEnum(flags, (ts as any).NodeCheckFlags, /*isFlags*/ true); +} - export function formatTransformFlags(flags: TransformFlags | undefined): string { - return formatEnum(flags, (ts as any).TransformFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatModifierFlags(flags: ModifierFlags | undefined): string { + return formatEnum(flags, (ts as any).ModifierFlags, /*isFlags*/ true); +} - export function formatEmitFlags(flags: EmitFlags | undefined): string { - return formatEnum(flags, (ts as any).EmitFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatTransformFlags(flags: TransformFlags | undefined): string { + return formatEnum(flags, (ts as any).TransformFlags, /*isFlags*/ true); +} - export function formatSymbolFlags(flags: SymbolFlags | undefined): string { - return formatEnum(flags, (ts as any).SymbolFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatEmitFlags(flags: EmitFlags | undefined): string { + return formatEnum(flags, (ts as any).EmitFlags, /*isFlags*/ true); +} - export function formatTypeFlags(flags: TypeFlags | undefined): string { - return formatEnum(flags, (ts as any).TypeFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatSymbolFlags(flags: SymbolFlags | undefined): string { + return formatEnum(flags, (ts as any).SymbolFlags, /*isFlags*/ true); +} - export function formatSignatureFlags(flags: SignatureFlags | undefined): string { - return formatEnum(flags, (ts as any).SignatureFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatTypeFlags(flags: TypeFlags | undefined): string { + return formatEnum(flags, (ts as any).TypeFlags, /*isFlags*/ true); +} - export function formatObjectFlags(flags: ObjectFlags | undefined): string { - return formatEnum(flags, (ts as any).ObjectFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatSignatureFlags(flags: SignatureFlags | undefined): string { + return formatEnum(flags, (ts as any).SignatureFlags, /*isFlags*/ true); +} - export function formatFlowFlags(flags: FlowFlags | undefined): string { - return formatEnum(flags, (ts as any).FlowFlags, /*isFlags*/ true); - } +/** @internal */ +export function formatObjectFlags(flags: ObjectFlags | undefined): string { + return formatEnum(flags, (ts as any).ObjectFlags, /*isFlags*/ true); +} - export function formatRelationComparisonResult(result: RelationComparisonResult | undefined): string { - return formatEnum(result, (ts as any).RelationComparisonResult, /*isFlags*/ true); - } +/** @internal */ +export function formatFlowFlags(flags: FlowFlags | undefined): string { + return formatEnum(flags, (ts as any).FlowFlags, /*isFlags*/ true); +} - export function formatCheckMode(mode: CheckMode | undefined): string { - return formatEnum(mode, (ts as any).CheckMode, /*isFlags*/ true); - } +/** @internal */ +export function formatRelationComparisonResult(result: RelationComparisonResult | undefined): string { + return formatEnum(result, (ts as any).RelationComparisonResult, /*isFlags*/ true); +} - export function formatSignatureCheckMode(mode: SignatureCheckMode | undefined): string { - return formatEnum(mode, (ts as any).SignatureCheckMode, /*isFlags*/ true); - } +/** @internal */ +export function formatCheckMode(mode: CheckMode | undefined): string { + return formatEnum(mode, (ts as any).CheckMode, /*isFlags*/ true); +} - export function formatTypeFacts(facts: TypeFacts | undefined): string { - return formatEnum(facts, (ts as any).TypeFacts, /*isFlags*/ true); - } +/** @internal */ +export function formatSignatureCheckMode(mode: SignatureCheckMode | undefined): string { + return formatEnum(mode, (ts as any).SignatureCheckMode, /*isFlags*/ true); +} - let isDebugInfoEnabled = false; +/** @internal */ +export function formatTypeFacts(facts: TypeFacts | undefined): string { + return formatEnum(facts, (ts as any).TypeFacts, /*isFlags*/ true); +} - let flowNodeProto: FlowNode | undefined; +let isDebugInfoEnabled = false; - function attachFlowNodeDebugInfoWorker(flowNode: FlowNode) { - if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line local/no-in-operator - Object.defineProperties(flowNode, { - // for use with vscode-js-debug's new customDescriptionGenerator in launch.json - __tsDebuggerDisplay: { - value(this: FlowNode) { - const flowHeader = this.flags & FlowFlags.Start ? "FlowStart" : - this.flags & FlowFlags.BranchLabel ? "FlowBranchLabel" : - this.flags & FlowFlags.LoopLabel ? "FlowLoopLabel" : - this.flags & FlowFlags.Assignment ? "FlowAssignment" : - this.flags & FlowFlags.TrueCondition ? "FlowTrueCondition" : - this.flags & FlowFlags.FalseCondition ? "FlowFalseCondition" : - this.flags & FlowFlags.SwitchClause ? "FlowSwitchClause" : - this.flags & FlowFlags.ArrayMutation ? "FlowArrayMutation" : - this.flags & FlowFlags.Call ? "FlowCall" : - this.flags & FlowFlags.ReduceLabel ? "FlowReduceLabel" : - this.flags & FlowFlags.Unreachable ? "FlowUnreachable" : - "UnknownFlow"; - const remainingFlags = this.flags & ~(FlowFlags.Referenced - 1); - return `${flowHeader}${remainingFlags ? ` (${formatFlowFlags(remainingFlags)})` : ""}`; - }, +let flowNodeProto: FlowNode | undefined; + +function attachFlowNodeDebugInfoWorker(flowNode: FlowNode) { + if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line local/no-in-operator + Object.defineProperties(flowNode, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value(this: FlowNode) { + const flowHeader = this.flags & FlowFlags.Start ? "FlowStart" : + this.flags & FlowFlags.BranchLabel ? "FlowBranchLabel" : + this.flags & FlowFlags.LoopLabel ? "FlowLoopLabel" : + this.flags & FlowFlags.Assignment ? "FlowAssignment" : + this.flags & FlowFlags.TrueCondition ? "FlowTrueCondition" : + this.flags & FlowFlags.FalseCondition ? "FlowFalseCondition" : + this.flags & FlowFlags.SwitchClause ? "FlowSwitchClause" : + this.flags & FlowFlags.ArrayMutation ? "FlowArrayMutation" : + this.flags & FlowFlags.Call ? "FlowCall" : + this.flags & FlowFlags.ReduceLabel ? "FlowReduceLabel" : + this.flags & FlowFlags.Unreachable ? "FlowUnreachable" : + "UnknownFlow"; + const remainingFlags = this.flags & ~(FlowFlags.Referenced - 1); + return `${flowHeader}${remainingFlags ? ` (${formatFlowFlags(remainingFlags)})` : ""}`; }, - __debugFlowFlags: { - get(this: FlowNode) { - return formatEnum(this.flags, (ts as any).FlowFlags, /*isFlags*/ true); - }, + }, + __debugFlowFlags: { + get(this: FlowNode) { + return formatEnum(this.flags, (ts as any).FlowFlags, /*isFlags*/ true); }, - __debugToString: { - value(this: FlowNode) { - return formatControlFlowGraph(this); - }, + }, + __debugToString: { + value(this: FlowNode) { + return formatControlFlowGraph(this); }, - }); - } + }, + }); } +} - export function attachFlowNodeDebugInfo(flowNode: FlowNode): FlowNode { - if (isDebugInfoEnabled) { - if (typeof Object.setPrototypeOf === "function") { - // if we're in es2015, attach the method to a shared prototype for `FlowNode` - // so the method doesn't show up in the watch window. - if (!flowNodeProto) { - flowNodeProto = Object.create(Object.prototype) as FlowNode; - attachFlowNodeDebugInfoWorker(flowNodeProto); - } - Object.setPrototypeOf(flowNode, flowNodeProto); - } - else { - // not running in an es2015 environment, attach the method directly. - attachFlowNodeDebugInfoWorker(flowNode); +/** @internal */ +export function attachFlowNodeDebugInfo(flowNode: FlowNode): FlowNode { + if (isDebugInfoEnabled) { + if (typeof Object.setPrototypeOf === "function") { + // if we're in es2015, attach the method to a shared prototype for `FlowNode` + // so the method doesn't show up in the watch window. + if (!flowNodeProto) { + flowNodeProto = Object.create(Object.prototype) as FlowNode; + attachFlowNodeDebugInfoWorker(flowNodeProto); } + Object.setPrototypeOf(flowNode, flowNodeProto); + } + else { + // not running in an es2015 environment, attach the method directly. + attachFlowNodeDebugInfoWorker(flowNode); } - return flowNode; } + return flowNode; +} - let nodeArrayProto: NodeArray | undefined; +let nodeArrayProto: NodeArray | undefined; - function attachNodeArrayDebugInfoWorker(array: NodeArray) { - if (!("__tsDebuggerDisplay" in array)) { // eslint-disable-line local/no-in-operator - Object.defineProperties(array, { - __tsDebuggerDisplay: { - value(this: NodeArray, defaultValue: string) { - // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of - // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the - // formatted string. - // This regex can trigger slow backtracking because of overlapping potential captures. - // We don't care, this is debug code that's only enabled with a debugger attached - - // we're just taking note of it for anyone checking regex performance in the future. - defaultValue = String(defaultValue).replace(/(?:,[\s\w]+:[^,]+)+\]$/, "]"); - return `NodeArray ${defaultValue}`; - }, +function attachNodeArrayDebugInfoWorker(array: NodeArray) { + if (!("__tsDebuggerDisplay" in array)) { // eslint-disable-line local/no-in-operator + Object.defineProperties(array, { + __tsDebuggerDisplay: { + value(this: NodeArray, defaultValue: string) { + // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of + // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the + // formatted string. + // This regex can trigger slow backtracking because of overlapping potential captures. + // We don't care, this is debug code that's only enabled with a debugger attached - + // we're just taking note of it for anyone checking regex performance in the future. + defaultValue = String(defaultValue).replace(/(?:,[\s\w]+:[^,]+)+\]$/, "]"); + return `NodeArray ${defaultValue}`; }, - }); - } + }, + }); } +} - export function attachNodeArrayDebugInfo(array: NodeArray): void { - if (isDebugInfoEnabled) { - if (typeof Object.setPrototypeOf === "function") { - // if we're in es2015, attach the method to a shared prototype for `NodeArray` - // so the method doesn't show up in the watch window. - if (!nodeArrayProto) { - nodeArrayProto = Object.create(Array.prototype) as NodeArray; - attachNodeArrayDebugInfoWorker(nodeArrayProto); - } - Object.setPrototypeOf(array, nodeArrayProto); - } - else { - // not running in an es2015 environment, attach the method directly. - attachNodeArrayDebugInfoWorker(array); +/** @internal */ +export function attachNodeArrayDebugInfo(array: NodeArray): void { + if (isDebugInfoEnabled) { + if (typeof Object.setPrototypeOf === "function") { + // if we're in es2015, attach the method to a shared prototype for `NodeArray` + // so the method doesn't show up in the watch window. + if (!nodeArrayProto) { + nodeArrayProto = Object.create(Array.prototype) as NodeArray; + attachNodeArrayDebugInfoWorker(nodeArrayProto); } + Object.setPrototypeOf(array, nodeArrayProto); + } + else { + // not running in an es2015 environment, attach the method directly. + attachNodeArrayDebugInfoWorker(array); } } +} - /** - * Injects debug information into frequently used types. - */ - export function enableDebugInfo(): void { - if (isDebugInfoEnabled) return; - - // avoid recomputing - const weakTypeTextMap = new WeakMap(); - const weakNodeTextMap = new WeakMap(); - - // Add additional properties in debug mode to assist with debugging. - Object.defineProperties(objectAllocator.getSymbolConstructor().prototype, { - // for use with vscode-js-debug's new customDescriptionGenerator in launch.json - __tsDebuggerDisplay: { - value(this: Symbol) { - const symbolHeader = this.flags & SymbolFlags.Transient ? "TransientSymbol" : - "Symbol"; - const remainingSymbolFlags = this.flags & ~SymbolFlags.Transient; - return `${symbolHeader} '${symbolName(this)}'${remainingSymbolFlags ? ` (${formatSymbolFlags(remainingSymbolFlags)})` : ""}`; - }, +/** + * Injects debug information into frequently used types. + * + * @internal + */ +export function enableDebugInfo(): void { + if (isDebugInfoEnabled) return; + + // avoid recomputing + const weakTypeTextMap = new WeakMap(); + const weakNodeTextMap = new WeakMap(); + + // Add additional properties in debug mode to assist with debugging. + Object.defineProperties(objectAllocator.getSymbolConstructor().prototype, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value(this: Symbol) { + const symbolHeader = this.flags & SymbolFlags.Transient ? "TransientSymbol" : + "Symbol"; + const remainingSymbolFlags = this.flags & ~SymbolFlags.Transient; + return `${symbolHeader} '${symbolName(this)}'${remainingSymbolFlags ? ` (${formatSymbolFlags(remainingSymbolFlags)})` : ""}`; }, - __debugFlags: { - get(this: Symbol) { - return formatSymbolFlags(this.flags); - }, + }, + __debugFlags: { + get(this: Symbol) { + return formatSymbolFlags(this.flags); }, - }); - - Object.defineProperties(objectAllocator.getTypeConstructor().prototype, { - // for use with vscode-js-debug's new customDescriptionGenerator in launch.json - __tsDebuggerDisplay: { - value(this: Type) { - const typeHeader = this.flags & TypeFlags.Intrinsic ? `IntrinsicType ${(this as IntrinsicType).intrinsicName}${(this as IntrinsicType).debugIntrinsicName ? ` (${(this as IntrinsicType).debugIntrinsicName})` : ""}` : - this.flags & TypeFlags.Nullable ? "NullableType" : - this.flags & TypeFlags.StringOrNumberLiteral ? `LiteralType ${JSON.stringify((this as LiteralType).value)}` : - this.flags & TypeFlags.BigIntLiteral ? `LiteralType ${(this as BigIntLiteralType).value.negative ? "-" : ""}${(this as BigIntLiteralType).value.base10Value}n` : - this.flags & TypeFlags.UniqueESSymbol ? "UniqueESSymbolType" : - this.flags & TypeFlags.Enum ? "EnumType" : - this.flags & TypeFlags.Union ? "UnionType" : - this.flags & TypeFlags.Intersection ? "IntersectionType" : - this.flags & TypeFlags.Index ? "IndexType" : - this.flags & TypeFlags.IndexedAccess ? "IndexedAccessType" : - this.flags & TypeFlags.Conditional ? "ConditionalType" : - this.flags & TypeFlags.Substitution ? "SubstitutionType" : - this.flags & TypeFlags.TypeParameter ? "TypeParameter" : - this.flags & TypeFlags.Object ? - (this as ObjectType).objectFlags & ObjectFlags.ClassOrInterface ? "InterfaceType" : - (this as ObjectType).objectFlags & ObjectFlags.Reference ? "TypeReference" : - (this as ObjectType).objectFlags & ObjectFlags.Tuple ? "TupleType" : - (this as ObjectType).objectFlags & ObjectFlags.Anonymous ? "AnonymousType" : - (this as ObjectType).objectFlags & ObjectFlags.Mapped ? "MappedType" : - (this as ObjectType).objectFlags & ObjectFlags.ReverseMapped ? "ReverseMappedType" : - (this as ObjectType).objectFlags & ObjectFlags.EvolvingArray ? "EvolvingArrayType" : - "ObjectType" : - "Type"; - const remainingObjectFlags = this.flags & TypeFlags.Object ? (this as ObjectType).objectFlags & ~ObjectFlags.ObjectTypeKindMask : 0; - return `${typeHeader}${this.symbol ? ` '${symbolName(this.symbol)}'` : ""}${remainingObjectFlags ? ` (${formatObjectFlags(remainingObjectFlags)})` : ""}`; - }, + }, + }); + + Object.defineProperties(objectAllocator.getTypeConstructor().prototype, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value(this: Type) { + const typeHeader = this.flags & TypeFlags.Intrinsic ? `IntrinsicType ${(this as IntrinsicType).intrinsicName}${(this as IntrinsicType).debugIntrinsicName ? ` (${(this as IntrinsicType).debugIntrinsicName})` : ""}` : + this.flags & TypeFlags.Nullable ? "NullableType" : + this.flags & TypeFlags.StringOrNumberLiteral ? `LiteralType ${JSON.stringify((this as LiteralType).value)}` : + this.flags & TypeFlags.BigIntLiteral ? `LiteralType ${(this as BigIntLiteralType).value.negative ? "-" : ""}${(this as BigIntLiteralType).value.base10Value}n` : + this.flags & TypeFlags.UniqueESSymbol ? "UniqueESSymbolType" : + this.flags & TypeFlags.Enum ? "EnumType" : + this.flags & TypeFlags.Union ? "UnionType" : + this.flags & TypeFlags.Intersection ? "IntersectionType" : + this.flags & TypeFlags.Index ? "IndexType" : + this.flags & TypeFlags.IndexedAccess ? "IndexedAccessType" : + this.flags & TypeFlags.Conditional ? "ConditionalType" : + this.flags & TypeFlags.Substitution ? "SubstitutionType" : + this.flags & TypeFlags.TypeParameter ? "TypeParameter" : + this.flags & TypeFlags.Object ? + (this as ObjectType).objectFlags & ObjectFlags.ClassOrInterface ? "InterfaceType" : + (this as ObjectType).objectFlags & ObjectFlags.Reference ? "TypeReference" : + (this as ObjectType).objectFlags & ObjectFlags.Tuple ? "TupleType" : + (this as ObjectType).objectFlags & ObjectFlags.Anonymous ? "AnonymousType" : + (this as ObjectType).objectFlags & ObjectFlags.Mapped ? "MappedType" : + (this as ObjectType).objectFlags & ObjectFlags.ReverseMapped ? "ReverseMappedType" : + (this as ObjectType).objectFlags & ObjectFlags.EvolvingArray ? "EvolvingArrayType" : + "ObjectType" : + "Type"; + const remainingObjectFlags = this.flags & TypeFlags.Object ? (this as ObjectType).objectFlags & ~ObjectFlags.ObjectTypeKindMask : 0; + return `${typeHeader}${this.symbol ? ` '${symbolName(this.symbol)}'` : ""}${remainingObjectFlags ? ` (${formatObjectFlags(remainingObjectFlags)})` : ""}`; }, - __debugFlags: { - get(this: Type) { - return formatTypeFlags(this.flags); - }, + }, + __debugFlags: { + get(this: Type) { + return formatTypeFlags(this.flags); }, - __debugObjectFlags: { - get(this: Type) { - return this.flags & TypeFlags.Object ? formatObjectFlags((this as ObjectType).objectFlags) : ""; - }, + }, + __debugObjectFlags: { + get(this: Type) { + return this.flags & TypeFlags.Object ? formatObjectFlags((this as ObjectType).objectFlags) : ""; }, - __debugTypeToString: { - value(this: Type) { - // avoid recomputing - let text = weakTypeTextMap.get(this); - if (text === undefined) { - text = this.checker.typeToString(this); - weakTypeTextMap.set(this, text); - } - return text; - }, + }, + __debugTypeToString: { + value(this: Type) { + // avoid recomputing + let text = weakTypeTextMap.get(this); + if (text === undefined) { + text = this.checker.typeToString(this); + weakTypeTextMap.set(this, text); + } + return text; }, - }); + }, + }); - Object.defineProperties(objectAllocator.getSignatureConstructor().prototype, { - __debugFlags: { - get(this: Signature) { - return formatSignatureFlags(this.flags); - }, + Object.defineProperties(objectAllocator.getSignatureConstructor().prototype, { + __debugFlags: { + get(this: Signature) { + return formatSignatureFlags(this.flags); }, - __debugSignatureToString: { - value(this: Signature) { - return this.checker?.signatureToString(this); - }, + }, + __debugSignatureToString: { + value(this: Signature) { + return this.checker?.signatureToString(this); }, - }); - - const nodeConstructors = [ - objectAllocator.getNodeConstructor(), - objectAllocator.getIdentifierConstructor(), - objectAllocator.getTokenConstructor(), - objectAllocator.getSourceFileConstructor(), - ]; - - for (const ctor of nodeConstructors) { - if (!hasProperty(ctor.prototype, "__debugKind")) { - Object.defineProperties(ctor.prototype, { - // for use with vscode-js-debug's new customDescriptionGenerator in launch.json - __tsDebuggerDisplay: { - value(this: Node) { - const nodeHeader = isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - isIdentifier(this) ? `Identifier '${idText(this)}'` : - isPrivateIdentifier(this) ? `PrivateIdentifier '${idText(this)}'` : - isStringLiteral(this) ? `StringLiteral ${JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")}` : - isNumericLiteral(this) ? `NumericLiteral ${this.text}` : - isBigIntLiteral(this) ? `BigIntLiteral ${this.text}n` : - isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : - isParameter(this) ? "ParameterDeclaration" : - isConstructorDeclaration(this) ? "ConstructorDeclaration" : - isGetAccessorDeclaration(this) ? "GetAccessorDeclaration" : - isSetAccessorDeclaration(this) ? "SetAccessorDeclaration" : - isCallSignatureDeclaration(this) ? "CallSignatureDeclaration" : - isConstructSignatureDeclaration(this) ? "ConstructSignatureDeclaration" : - isIndexSignatureDeclaration(this) ? "IndexSignatureDeclaration" : - isTypePredicateNode(this) ? "TypePredicateNode" : - isTypeReferenceNode(this) ? "TypeReferenceNode" : - isFunctionTypeNode(this) ? "FunctionTypeNode" : - isConstructorTypeNode(this) ? "ConstructorTypeNode" : - isTypeQueryNode(this) ? "TypeQueryNode" : - isTypeLiteralNode(this) ? "TypeLiteralNode" : - isArrayTypeNode(this) ? "ArrayTypeNode" : - isTupleTypeNode(this) ? "TupleTypeNode" : - isOptionalTypeNode(this) ? "OptionalTypeNode" : - isRestTypeNode(this) ? "RestTypeNode" : - isUnionTypeNode(this) ? "UnionTypeNode" : - isIntersectionTypeNode(this) ? "IntersectionTypeNode" : - isConditionalTypeNode(this) ? "ConditionalTypeNode" : - isInferTypeNode(this) ? "InferTypeNode" : - isParenthesizedTypeNode(this) ? "ParenthesizedTypeNode" : - isThisTypeNode(this) ? "ThisTypeNode" : - isTypeOperatorNode(this) ? "TypeOperatorNode" : - isIndexedAccessTypeNode(this) ? "IndexedAccessTypeNode" : - isMappedTypeNode(this) ? "MappedTypeNode" : - isLiteralTypeNode(this) ? "LiteralTypeNode" : - isNamedTupleMember(this) ? "NamedTupleMember" : - isImportTypeNode(this) ? "ImportTypeNode" : - formatSyntaxKind(this.kind); - return `${nodeHeader}${this.flags ? ` (${formatNodeFlags(this.flags)})` : ""}`; - }, + }, + }); + + const nodeConstructors = [ + objectAllocator.getNodeConstructor(), + objectAllocator.getIdentifierConstructor(), + objectAllocator.getTokenConstructor(), + objectAllocator.getSourceFileConstructor(), + ]; + + for (const ctor of nodeConstructors) { + if (!hasProperty(ctor.prototype, "__debugKind")) { + Object.defineProperties(ctor.prototype, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value(this: Node) { + const nodeHeader = isGeneratedIdentifier(this) ? "GeneratedIdentifier" : + isIdentifier(this) ? `Identifier '${idText(this)}'` : + isPrivateIdentifier(this) ? `PrivateIdentifier '${idText(this)}'` : + isStringLiteral(this) ? `StringLiteral ${JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")}` : + isNumericLiteral(this) ? `NumericLiteral ${this.text}` : + isBigIntLiteral(this) ? `BigIntLiteral ${this.text}n` : + isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : + isParameter(this) ? "ParameterDeclaration" : + isConstructorDeclaration(this) ? "ConstructorDeclaration" : + isGetAccessorDeclaration(this) ? "GetAccessorDeclaration" : + isSetAccessorDeclaration(this) ? "SetAccessorDeclaration" : + isCallSignatureDeclaration(this) ? "CallSignatureDeclaration" : + isConstructSignatureDeclaration(this) ? "ConstructSignatureDeclaration" : + isIndexSignatureDeclaration(this) ? "IndexSignatureDeclaration" : + isTypePredicateNode(this) ? "TypePredicateNode" : + isTypeReferenceNode(this) ? "TypeReferenceNode" : + isFunctionTypeNode(this) ? "FunctionTypeNode" : + isConstructorTypeNode(this) ? "ConstructorTypeNode" : + isTypeQueryNode(this) ? "TypeQueryNode" : + isTypeLiteralNode(this) ? "TypeLiteralNode" : + isArrayTypeNode(this) ? "ArrayTypeNode" : + isTupleTypeNode(this) ? "TupleTypeNode" : + isOptionalTypeNode(this) ? "OptionalTypeNode" : + isRestTypeNode(this) ? "RestTypeNode" : + isUnionTypeNode(this) ? "UnionTypeNode" : + isIntersectionTypeNode(this) ? "IntersectionTypeNode" : + isConditionalTypeNode(this) ? "ConditionalTypeNode" : + isInferTypeNode(this) ? "InferTypeNode" : + isParenthesizedTypeNode(this) ? "ParenthesizedTypeNode" : + isThisTypeNode(this) ? "ThisTypeNode" : + isTypeOperatorNode(this) ? "TypeOperatorNode" : + isIndexedAccessTypeNode(this) ? "IndexedAccessTypeNode" : + isMappedTypeNode(this) ? "MappedTypeNode" : + isLiteralTypeNode(this) ? "LiteralTypeNode" : + isNamedTupleMember(this) ? "NamedTupleMember" : + isImportTypeNode(this) ? "ImportTypeNode" : + formatSyntaxKind(this.kind); + return `${nodeHeader}${this.flags ? ` (${formatNodeFlags(this.flags)})` : ""}`; }, - __debugKind: { - get(this: Node) { - return formatSyntaxKind(this.kind); - }, + }, + __debugKind: { + get(this: Node) { + return formatSyntaxKind(this.kind); }, - __debugNodeFlags: { - get(this: Node) { - return formatNodeFlags(this.flags); - }, + }, + __debugNodeFlags: { + get(this: Node) { + return formatNodeFlags(this.flags); }, - __debugModifierFlags: { - get(this: Node) { - return formatModifierFlags(getEffectiveModifierFlagsNoCache(this)); - }, + }, + __debugModifierFlags: { + get(this: Node) { + return formatModifierFlags(getEffectiveModifierFlagsNoCache(this)); }, - __debugTransformFlags: { - get(this: Node) { - return formatTransformFlags(this.transformFlags); - }, + }, + __debugTransformFlags: { + get(this: Node) { + return formatTransformFlags(this.transformFlags); }, - __debugIsParseTreeNode: { - get(this: Node) { - return isParseTreeNode(this); - }, + }, + __debugIsParseTreeNode: { + get(this: Node) { + return isParseTreeNode(this); }, - __debugEmitFlags: { - get(this: Node) { - return formatEmitFlags(getEmitFlags(this)); - }, + }, + __debugEmitFlags: { + get(this: Node) { + return formatEmitFlags(getEmitFlags(this)); }, - __debugGetText: { - value(this: Node, includeTrivia?: boolean) { - if (nodeIsSynthesized(this)) return ""; - // avoid recomputing - let text = weakNodeTextMap.get(this); - if (text === undefined) { - const parseNode = getParseTreeNode(this); - const sourceFile = parseNode && getSourceFileOfNode(parseNode); - text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : ""; - weakNodeTextMap.set(this, text); - } - return text; - }, + }, + __debugGetText: { + value(this: Node, includeTrivia?: boolean) { + if (nodeIsSynthesized(this)) return ""; + // avoid recomputing + let text = weakNodeTextMap.get(this); + if (text === undefined) { + const parseNode = getParseTreeNode(this); + const sourceFile = parseNode && getSourceFileOfNode(parseNode); + text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : ""; + weakNodeTextMap.set(this, text); + } + return text; }, - }); - } + }, + }); } - - isDebugInfoEnabled = true; } - export function formatVariance(varianceFlags: VarianceFlags): string { - const variance = varianceFlags & VarianceFlags.VarianceMask; - let result = variance === VarianceFlags.Invariant ? "in out" : - variance === VarianceFlags.Bivariant ? "[bivariant]" : - variance === VarianceFlags.Contravariant ? "in" : - variance === VarianceFlags.Covariant ? "out" : - variance === VarianceFlags.Independent ? "[independent]" : ""; - if (varianceFlags & VarianceFlags.Unmeasurable) { - result += " (unmeasurable)"; - } - else if (varianceFlags & VarianceFlags.Unreliable) { - result += " (unreliable)"; - } - return result; + isDebugInfoEnabled = true; +} + +/** @internal */ +export function formatVariance(varianceFlags: VarianceFlags): string { + const variance = varianceFlags & VarianceFlags.VarianceMask; + let result = variance === VarianceFlags.Invariant ? "in out" : + variance === VarianceFlags.Bivariant ? "[bivariant]" : + variance === VarianceFlags.Contravariant ? "in" : + variance === VarianceFlags.Covariant ? "out" : + variance === VarianceFlags.Independent ? "[independent]" : ""; + if (varianceFlags & VarianceFlags.Unmeasurable) { + result += " (unmeasurable)"; } + else if (varianceFlags & VarianceFlags.Unreliable) { + result += " (unreliable)"; + } + return result; +} - export type DebugType = Type & { __debugTypeToString(): string; }; // eslint-disable-line @typescript-eslint/naming-convention - export class DebugTypeMapper { - declare kind: TypeMapKind; - __debugToString(): string { // eslint-disable-line @typescript-eslint/naming-convention - type(this); - switch (this.kind) { - case TypeMapKind.Function: - return this.debugInfo?.() || "(function mapper)"; - case TypeMapKind.Simple: - return `${(this.source as DebugType).__debugTypeToString()} -> ${(this.target as DebugType).__debugTypeToString()}`; - case TypeMapKind.Array: - return zipWith( - this.sources as readonly DebugType[], - this.targets as readonly DebugType[] || map(this.sources, () => "any"), - (s, t) => `${s.__debugTypeToString()} -> ${typeof t === "string" ? t : t.__debugTypeToString()}`, - ).join(", "); - case TypeMapKind.Deferred: - return zipWith( - this.sources, - this.targets, - (s, t) => `${(s as DebugType).__debugTypeToString()} -> ${(t() as DebugType).__debugTypeToString()}`, - ).join(", "); - case TypeMapKind.Merged: - case TypeMapKind.Composite: - return `m1: ${(this.mapper1 as unknown as DebugTypeMapper).__debugToString().split("\n").join("\n ")} +/** @internal */ +export type DebugType = Type & { __debugTypeToString(): string; }; // eslint-disable-line @typescript-eslint/naming-convention +/** @internal */ +export class DebugTypeMapper { + declare kind: TypeMapKind; + __debugToString(): string { // eslint-disable-line @typescript-eslint/naming-convention + assertType(this); + switch (this.kind) { + case TypeMapKind.Function: + return this.debugInfo?.() || "(function mapper)"; + case TypeMapKind.Simple: + return `${(this.source as DebugType).__debugTypeToString()} -> ${(this.target as DebugType).__debugTypeToString()}`; + case TypeMapKind.Array: + return zipWith( + this.sources as readonly DebugType[], + this.targets as readonly DebugType[] || map(this.sources, () => "any"), + (s, t) => `${s.__debugTypeToString()} -> ${typeof t === "string" ? t : t.__debugTypeToString()}`, + ).join(", "); + case TypeMapKind.Deferred: + return zipWith( + this.sources, + this.targets, + (s, t) => `${(s as DebugType).__debugTypeToString()} -> ${(t() as DebugType).__debugTypeToString()}`, + ).join(", "); + case TypeMapKind.Merged: + case TypeMapKind.Composite: + return `m1: ${(this.mapper1 as unknown as DebugTypeMapper).__debugToString().split("\n").join("\n ")} m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n").join("\n ")}`; - default: - return assertNever(this); - } + default: + return assertNever(this); } } +} - export function attachDebugPrototypeIfDebug(mapper: TypeMapper): TypeMapper { - if (isDebugging) { - return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype); - } - return mapper; +/** @internal */ +export function attachDebugPrototypeIfDebug(mapper: TypeMapper): TypeMapper { + if (isDebugging) { + return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype); } + return mapper; +} - export function printControlFlowGraph(flowNode: FlowNode): void { - return console.log(formatControlFlowGraph(flowNode)); - } +/** @internal */ +export function printControlFlowGraph(flowNode: FlowNode): void { + return console.log(formatControlFlowGraph(flowNode)); +} - export function formatControlFlowGraph(flowNode: FlowNode): string { - let nextDebugFlowId = -1; +/** @internal */ +export function formatControlFlowGraph(flowNode: FlowNode): string { + let nextDebugFlowId = -1; - function getDebugFlowNodeId(f: FlowNode) { - if (!f.id) { - f.id = nextDebugFlowId; - nextDebugFlowId--; - } - return f.id; + function getDebugFlowNodeId(f: FlowNode) { + if (!f.id) { + f.id = nextDebugFlowId; + nextDebugFlowId--; } + return f.id; + } - const enum BoxCharacter { - lr = "─", - ud = "│", - dr = "╭", - dl = "╮", - ul = "╯", - ur = "╰", - udr = "├", - udl = "┤", - dlr = "┬", - ulr = "┴", - udlr = "╫", - } + const enum BoxCharacter { + lr = "─", + ud = "│", + dr = "╭", + dl = "╮", + ul = "╯", + ur = "╰", + udr = "├", + udl = "┤", + dlr = "┬", + ulr = "┴", + udlr = "╫", + } - const enum Connection { - None = 0, - Up = 1 << 0, - Down = 1 << 1, - Left = 1 << 2, - Right = 1 << 3, - - UpDown = Up | Down, - LeftRight = Left | Right, - UpLeft = Up | Left, - UpRight = Up | Right, - DownLeft = Down | Left, - DownRight = Down | Right, - UpDownLeft = UpDown | Left, - UpDownRight = UpDown | Right, - UpLeftRight = Up | LeftRight, - DownLeftRight = Down | LeftRight, - UpDownLeftRight = UpDown | LeftRight, - - NoChildren = 1 << 4, - } + const enum Connection { + None = 0, + Up = 1 << 0, + Down = 1 << 1, + Left = 1 << 2, + Right = 1 << 3, + + UpDown = Up | Down, + LeftRight = Left | Right, + UpLeft = Up | Left, + UpRight = Up | Right, + DownLeft = Down | Left, + DownRight = Down | Right, + UpDownLeft = UpDown | Left, + UpDownRight = UpDown | Right, + UpLeftRight = Up | LeftRight, + DownLeftRight = Down | LeftRight, + UpDownLeftRight = UpDown | LeftRight, + + NoChildren = 1 << 4, + } - interface FlowGraphNode { - id: number; - flowNode: FlowNode; - edges: FlowGraphEdge[]; - text: string; - lane: number; - endLane: number; - level: number; - circular: boolean | "circularity"; - } + interface FlowGraphNode { + id: number; + flowNode: FlowNode; + edges: FlowGraphEdge[]; + text: string; + lane: number; + endLane: number; + level: number; + circular: boolean | "circularity"; + } - interface FlowGraphEdge { - source: FlowGraphNode; - target: FlowGraphNode; - } + interface FlowGraphEdge { + source: FlowGraphNode; + target: FlowGraphNode; + } - const hasAntecedentFlags = FlowFlags.Assignment | - FlowFlags.Condition | - FlowFlags.SwitchClause | - FlowFlags.ArrayMutation | - FlowFlags.Call | - FlowFlags.ReduceLabel; - - const hasNodeFlags = FlowFlags.Start | - FlowFlags.Assignment | - FlowFlags.Call | - FlowFlags.Condition | - FlowFlags.ArrayMutation; - - const links: Record = Object.create(/*o*/ null); // eslint-disable-line no-restricted-syntax - const nodes: FlowGraphNode[] = []; - const edges: FlowGraphEdge[] = []; - const root = buildGraphNode(flowNode, new Set()); - for (const node of nodes) { - node.text = renderFlowNode(node.flowNode, node.circular); - computeLevel(node); - } + const hasAntecedentFlags = FlowFlags.Assignment | + FlowFlags.Condition | + FlowFlags.SwitchClause | + FlowFlags.ArrayMutation | + FlowFlags.Call | + FlowFlags.ReduceLabel; + + const hasNodeFlags = FlowFlags.Start | + FlowFlags.Assignment | + FlowFlags.Call | + FlowFlags.Condition | + FlowFlags.ArrayMutation; + + const links: Record = Object.create(/*o*/ null); // eslint-disable-line no-restricted-syntax + const nodes: FlowGraphNode[] = []; + const edges: FlowGraphEdge[] = []; + const root = buildGraphNode(flowNode, new Set()); + for (const node of nodes) { + node.text = renderFlowNode(node.flowNode, node.circular); + computeLevel(node); + } - const height = computeHeight(root); - const columnWidths = computeColumnWidths(height); - computeLanes(root, 0); - return renderGraph(); + const height = computeHeight(root); + const columnWidths = computeColumnWidths(height); + computeLanes(root, 0); + return renderGraph(); - function isFlowSwitchClause(f: FlowNode): f is FlowSwitchClause { - return !!(f.flags & FlowFlags.SwitchClause); - } + function isFlowSwitchClause(f: FlowNode): f is FlowSwitchClause { + return !!(f.flags & FlowFlags.SwitchClause); + } - function hasAntecedents(f: FlowNode): f is FlowLabel & { antecedent: FlowNode[]; } { - return !!(f.flags & FlowFlags.Label) && !!(f as FlowLabel).antecedent; - } + function hasAntecedents(f: FlowNode): f is FlowLabel & { antecedent: FlowNode[]; } { + return !!(f.flags & FlowFlags.Label) && !!(f as FlowLabel).antecedent; + } - function hasAntecedent(f: FlowNode): f is Extract { - return !!(f.flags & hasAntecedentFlags); - } + function hasAntecedent(f: FlowNode): f is Extract { + return !!(f.flags & hasAntecedentFlags); + } - function hasNode(f: FlowNode): f is Extract { - return !!(f.flags & hasNodeFlags); - } + function hasNode(f: FlowNode): f is Extract { + return !!(f.flags & hasNodeFlags); + } - function getChildren(node: FlowGraphNode) { - const children: FlowGraphNode[] = []; - for (const edge of node.edges) { - if (edge.source === node) { - children.push(edge.target); - } + function getChildren(node: FlowGraphNode) { + const children: FlowGraphNode[] = []; + for (const edge of node.edges) { + if (edge.source === node) { + children.push(edge.target); } - return children; } + return children; + } - function getParents(node: FlowGraphNode) { - const parents: FlowGraphNode[] = []; - for (const edge of node.edges) { - if (edge.target === node) { - parents.push(edge.source); - } + function getParents(node: FlowGraphNode) { + const parents: FlowGraphNode[] = []; + for (const edge of node.edges) { + if (edge.target === node) { + parents.push(edge.source); } - return parents; } + return parents; + } - function buildGraphNode(flowNode: FlowNode, seen: Set): FlowGraphNode { - const id = getDebugFlowNodeId(flowNode); - let graphNode = links[id]; - if (graphNode && seen.has(flowNode)) { - graphNode.circular = true; - graphNode = { - id: -1, - flowNode, - edges: [], - text: "", - lane: -1, - endLane: -1, - level: -1, - circular: "circularity", - }; - nodes.push(graphNode); - return graphNode; - } - seen.add(flowNode); - if (!graphNode) { - links[id] = graphNode = { id, flowNode, edges: [], text: "", lane: -1, endLane: -1, level: -1, circular: false }; - nodes.push(graphNode); - if (hasAntecedents(flowNode)) { - for (const antecedent of flowNode.antecedent) { - buildGraphEdge(graphNode, antecedent, seen); - } - } - else if (hasAntecedent(flowNode)) { - buildGraphEdge(graphNode, flowNode.antecedent, seen); + function buildGraphNode(flowNode: FlowNode, seen: Set): FlowGraphNode { + const id = getDebugFlowNodeId(flowNode); + let graphNode = links[id]; + if (graphNode && seen.has(flowNode)) { + graphNode.circular = true; + graphNode = { + id: -1, + flowNode, + edges: [], + text: "", + lane: -1, + endLane: -1, + level: -1, + circular: "circularity", + }; + nodes.push(graphNode); + return graphNode; + } + seen.add(flowNode); + if (!graphNode) { + links[id] = graphNode = { id, flowNode, edges: [], text: "", lane: -1, endLane: -1, level: -1, circular: false }; + nodes.push(graphNode); + if (hasAntecedents(flowNode)) { + for (const antecedent of flowNode.antecedent) { + buildGraphEdge(graphNode, antecedent, seen); } } - seen.delete(flowNode); - return graphNode; + else if (hasAntecedent(flowNode)) { + buildGraphEdge(graphNode, flowNode.antecedent, seen); + } } + seen.delete(flowNode); + return graphNode; + } + + function buildGraphEdge(source: FlowGraphNode, antecedent: FlowNode, seen: Set) { + const target = buildGraphNode(antecedent, seen); + const edge: FlowGraphEdge = { source, target }; + edges.push(edge); + source.edges.push(edge); + target.edges.push(edge); + } - function buildGraphEdge(source: FlowGraphNode, antecedent: FlowNode, seen: Set) { - const target = buildGraphNode(antecedent, seen); - const edge: FlowGraphEdge = { source, target }; - edges.push(edge); - source.edges.push(edge); - target.edges.push(edge); + function computeLevel(node: FlowGraphNode): number { + if (node.level !== -1) { + return node.level; } + let level = 0; + for (const parent of getParents(node)) { + level = Math.max(level, computeLevel(parent) + 1); + } + return node.level = level; + } - function computeLevel(node: FlowGraphNode): number { - if (node.level !== -1) { - return node.level; - } - let level = 0; - for (const parent of getParents(node)) { - level = Math.max(level, computeLevel(parent) + 1); - } - return node.level = level; + function computeHeight(node: FlowGraphNode): number { + let height = 0; + for (const child of getChildren(node)) { + height = Math.max(height, computeHeight(child)); } + return height + 1; + } - function computeHeight(node: FlowGraphNode): number { - let height = 0; - for (const child of getChildren(node)) { - height = Math.max(height, computeHeight(child)); - } - return height + 1; + function computeColumnWidths(height: number) { + const columns: number[] = fill(Array(height), 0); + for (const node of nodes) { + columns[node.level] = Math.max(columns[node.level], node.text.length); } + return columns; + } - function computeColumnWidths(height: number) { - const columns: number[] = fill(Array(height), 0); - for (const node of nodes) { - columns[node.level] = Math.max(columns[node.level], node.text.length); + function computeLanes(node: FlowGraphNode, lane: number) { + if (node.lane === -1) { + node.lane = lane; + node.endLane = lane; + const children = getChildren(node); + for (let i = 0; i < children.length; i++) { + if (i > 0) lane++; + const child = children[i]; + computeLanes(child, lane); + if (child.endLane > node.endLane) { + lane = child.endLane; + } } - return columns; + node.endLane = lane; } + } - function computeLanes(node: FlowGraphNode, lane: number) { - if (node.lane === -1) { - node.lane = lane; - node.endLane = lane; - const children = getChildren(node); - for (let i = 0; i < children.length; i++) { - if (i > 0) lane++; - const child = children[i]; - computeLanes(child, lane); - if (child.endLane > node.endLane) { - lane = child.endLane; - } + function getHeader(flags: FlowFlags) { + if (flags & FlowFlags.Start) return "Start"; + if (flags & FlowFlags.BranchLabel) return "Branch"; + if (flags & FlowFlags.LoopLabel) return "Loop"; + if (flags & FlowFlags.Assignment) return "Assignment"; + if (flags & FlowFlags.TrueCondition) return "True"; + if (flags & FlowFlags.FalseCondition) return "False"; + if (flags & FlowFlags.SwitchClause) return "SwitchClause"; + if (flags & FlowFlags.ArrayMutation) return "ArrayMutation"; + if (flags & FlowFlags.Call) return "Call"; + if (flags & FlowFlags.ReduceLabel) return "ReduceLabel"; + if (flags & FlowFlags.Unreachable) return "Unreachable"; + throw new Error(); + } + + function getNodeText(node: Node) { + const sourceFile = getSourceFileOfNode(node); + return getSourceTextOfNodeFromSourceFile(sourceFile, node, /*includeTrivia*/ false); + } + + function renderFlowNode(flowNode: FlowNode, circular: boolean | "circularity") { + let text = getHeader(flowNode.flags); + if (circular) { + text = `${text}#${getDebugFlowNodeId(flowNode)}`; + } + if (isFlowSwitchClause(flowNode)) { + const clauses: string[] = []; + const { switchStatement, clauseStart, clauseEnd } = flowNode.node; + for (let i = clauseStart; i < clauseEnd; i++) { + const clause = switchStatement.caseBlock.clauses[i]; + if (isDefaultClause(clause)) { + clauses.push("default"); + } + else { + clauses.push(getNodeText(clause.expression)); } - node.endLane = lane; } + text += ` (${clauses.join(", ")})`; } - - function getHeader(flags: FlowFlags) { - if (flags & FlowFlags.Start) return "Start"; - if (flags & FlowFlags.BranchLabel) return "Branch"; - if (flags & FlowFlags.LoopLabel) return "Loop"; - if (flags & FlowFlags.Assignment) return "Assignment"; - if (flags & FlowFlags.TrueCondition) return "True"; - if (flags & FlowFlags.FalseCondition) return "False"; - if (flags & FlowFlags.SwitchClause) return "SwitchClause"; - if (flags & FlowFlags.ArrayMutation) return "ArrayMutation"; - if (flags & FlowFlags.Call) return "Call"; - if (flags & FlowFlags.ReduceLabel) return "ReduceLabel"; - if (flags & FlowFlags.Unreachable) return "Unreachable"; - throw new Error(); + else if (hasNode(flowNode)) { + if (flowNode.node) { + text += ` (${getNodeText(flowNode.node)})`; + } } + return circular === "circularity" ? `Circular(${text})` : text; + } - function getNodeText(node: Node) { - const sourceFile = getSourceFileOfNode(node); - return getSourceTextOfNodeFromSourceFile(sourceFile, node, /*includeTrivia*/ false); - } + function renderGraph() { + const columnCount = columnWidths.length; + const laneCount = maxBy(nodes, 0, n => n.lane) + 1; + const lanes: string[] = fill(Array(laneCount), ""); + const grid: (FlowGraphNode | undefined)[][] = columnWidths.map(() => Array(laneCount)); + const connectors: Connection[][] = columnWidths.map(() => fill(Array(laneCount), 0)); - function renderFlowNode(flowNode: FlowNode, circular: boolean | "circularity") { - let text = getHeader(flowNode.flags); - if (circular) { - text = `${text}#${getDebugFlowNodeId(flowNode)}`; + // build connectors + for (const node of nodes) { + grid[node.level][node.lane] = node; + const children = getChildren(node); + for (let i = 0; i < children.length; i++) { + const child = children[i]; + let connector: Connection = Connection.Right; + if (child.lane === node.lane) connector |= Connection.Left; + if (i > 0) connector |= Connection.Up; + if (i < children.length - 1) connector |= Connection.Down; + connectors[node.level][child.lane] |= connector; } - if (isFlowSwitchClause(flowNode)) { - const clauses: string[] = []; - const { switchStatement, clauseStart, clauseEnd } = flowNode.node; - for (let i = clauseStart; i < clauseEnd; i++) { - const clause = switchStatement.caseBlock.clauses[i]; - if (isDefaultClause(clause)) { - clauses.push("default"); - } - else { - clauses.push(getNodeText(clause.expression)); - } - } - text += ` (${clauses.join(", ")})`; + if (children.length === 0) { + connectors[node.level][node.lane] |= Connection.NoChildren; } - else if (hasNode(flowNode)) { - if (flowNode.node) { - text += ` (${getNodeText(flowNode.node)})`; - } + const parents = getParents(node); + for (let i = 0; i < parents.length; i++) { + const parent = parents[i]; + let connector: Connection = Connection.Left; + if (i > 0) connector |= Connection.Up; + if (i < parents.length - 1) connector |= Connection.Down; + connectors[node.level - 1][parent.lane] |= connector; } - return circular === "circularity" ? `Circular(${text})` : text; } - function renderGraph() { - const columnCount = columnWidths.length; - const laneCount = maxBy(nodes, 0, n => n.lane) + 1; - const lanes: string[] = fill(Array(laneCount), ""); - const grid: (FlowGraphNode | undefined)[][] = columnWidths.map(() => Array(laneCount)); - const connectors: Connection[][] = columnWidths.map(() => fill(Array(laneCount), 0)); - - // build connectors - for (const node of nodes) { - grid[node.level][node.lane] = node; - const children = getChildren(node); - for (let i = 0; i < children.length; i++) { - const child = children[i]; - let connector: Connection = Connection.Right; - if (child.lane === node.lane) connector |= Connection.Left; - if (i > 0) connector |= Connection.Up; - if (i < children.length - 1) connector |= Connection.Down; - connectors[node.level][child.lane] |= connector; - } - if (children.length === 0) { - connectors[node.level][node.lane] |= Connection.NoChildren; - } - const parents = getParents(node); - for (let i = 0; i < parents.length; i++) { - const parent = parents[i]; - let connector: Connection = Connection.Left; - if (i > 0) connector |= Connection.Up; - if (i < parents.length - 1) connector |= Connection.Down; - connectors[node.level - 1][parent.lane] |= connector; + // fill in missing connectors + for (let column = 0; column < columnCount; column++) { + for (let lane = 0; lane < laneCount; lane++) { + const left = column > 0 ? connectors[column - 1][lane] : 0; + const above = lane > 0 ? connectors[column][lane - 1] : 0; + let connector = connectors[column][lane]; + if (!connector) { + if (left & Connection.Right) connector |= Connection.LeftRight; + if (above & Connection.Down) connector |= Connection.UpDown; + connectors[column][lane] = connector; } } + } - // fill in missing connectors - for (let column = 0; column < columnCount; column++) { - for (let lane = 0; lane < laneCount; lane++) { - const left = column > 0 ? connectors[column - 1][lane] : 0; - const above = lane > 0 ? connectors[column][lane - 1] : 0; - let connector = connectors[column][lane]; - if (!connector) { - if (left & Connection.Right) connector |= Connection.LeftRight; - if (above & Connection.Down) connector |= Connection.UpDown; - connectors[column][lane] = connector; + for (let column = 0; column < columnCount; column++) { + for (let lane = 0; lane < lanes.length; lane++) { + const connector = connectors[column][lane]; + const fill = connector & Connection.Left ? BoxCharacter.lr : " "; + const node = grid[column][lane]; + if (!node) { + if (column < columnCount - 1) { + writeLane(lane, repeat(fill, columnWidths[column] + 1)); } } - } - - for (let column = 0; column < columnCount; column++) { - for (let lane = 0; lane < lanes.length; lane++) { - const connector = connectors[column][lane]; - const fill = connector & Connection.Left ? BoxCharacter.lr : " "; - const node = grid[column][lane]; - if (!node) { - if (column < columnCount - 1) { - writeLane(lane, repeat(fill, columnWidths[column] + 1)); - } - } - else { - writeLane(lane, node.text); - if (column < columnCount - 1) { - writeLane(lane, " "); - writeLane(lane, repeat(fill, columnWidths[column] - node.text.length)); - } + else { + writeLane(lane, node.text); + if (column < columnCount - 1) { + writeLane(lane, " "); + writeLane(lane, repeat(fill, columnWidths[column] - node.text.length)); } - writeLane(lane, getBoxCharacter(connector)); - writeLane(lane, connector & Connection.Right && column < columnCount - 1 && !grid[column + 1][lane] ? BoxCharacter.lr : " "); } + writeLane(lane, getBoxCharacter(connector)); + writeLane(lane, connector & Connection.Right && column < columnCount - 1 && !grid[column + 1][lane] ? BoxCharacter.lr : " "); } + } - return `\n${lanes.join("\n")}\n`; + return `\n${lanes.join("\n")}\n`; - function writeLane(lane: number, text: string) { - lanes[lane] += text; - } + function writeLane(lane: number, text: string) { + lanes[lane] += text; } + } - function getBoxCharacter(connector: Connection) { - switch (connector) { - case Connection.UpDown: - return BoxCharacter.ud; - case Connection.LeftRight: - return BoxCharacter.lr; - case Connection.UpLeft: - return BoxCharacter.ul; - case Connection.UpRight: - return BoxCharacter.ur; - case Connection.DownLeft: - return BoxCharacter.dl; - case Connection.DownRight: - return BoxCharacter.dr; - case Connection.UpDownLeft: - return BoxCharacter.udl; - case Connection.UpDownRight: - return BoxCharacter.udr; - case Connection.UpLeftRight: - return BoxCharacter.ulr; - case Connection.DownLeftRight: - return BoxCharacter.dlr; - case Connection.UpDownLeftRight: - return BoxCharacter.udlr; - } - return " "; + function getBoxCharacter(connector: Connection) { + switch (connector) { + case Connection.UpDown: + return BoxCharacter.ud; + case Connection.LeftRight: + return BoxCharacter.lr; + case Connection.UpLeft: + return BoxCharacter.ul; + case Connection.UpRight: + return BoxCharacter.ur; + case Connection.DownLeft: + return BoxCharacter.dl; + case Connection.DownRight: + return BoxCharacter.dr; + case Connection.UpDownLeft: + return BoxCharacter.udl; + case Connection.UpDownRight: + return BoxCharacter.udr; + case Connection.UpLeftRight: + return BoxCharacter.ulr; + case Connection.DownLeftRight: + return BoxCharacter.dlr; + case Connection.UpDownLeftRight: + return BoxCharacter.udlr; } + return " "; + } - function fill(array: T[], value: T) { - if (array.fill) { - array.fill(value); - } - else { - for (let i = 0; i < array.length; i++) { - array[i] = value; - } + function fill(array: T[], value: T) { + if (array.fill) { + array.fill(value); + } + else { + for (let i = 0; i < array.length; i++) { + array[i] = value; } - return array; } + return array; + } - function repeat(ch: string, length: number) { - if (ch.repeat) { - return length > 0 ? ch.repeat(length) : ""; - } - let s = ""; - while (s.length < length) { - s += ch; - } - return s; + function repeat(ch: string, length: number) { + if (ch.repeat) { + return length > 0 ? ch.repeat(length) : ""; + } + let s = ""; + while (s.length < length) { + s += ch; } + return s; } } diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 9f7cc54ef7508..5261459afc862 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -4,7 +4,6 @@ import { addInternalEmitFlags, AdditiveOperator, AdditiveOperatorOrHigher, - AssertionLevel, AssignmentExpression, AssignmentOperatorOrHigher, AssignmentPattern, @@ -1396,7 +1395,7 @@ namespace BinaryExpressionState { } function checkCircularity(stackIndex: number, nodeStack: BinaryExpression[], node: BinaryExpression) { - if (Debug.shouldAssert(AssertionLevel.Aggressive)) { + if (Debug.shouldAssert(Debug.AssertionLevel.Aggressive)) { while (stackIndex >= 0) { Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index ac433ba8fed10..caf36f7bd5a37 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -812,7 +812,7 @@ function getAllModulePathsWorker(info: Info, importedFileName: string, host: Mod const cache = host.getModuleResolutionCache?.(); const links = host.getSymlinkCache?.(); if (cache && links && host.readFile && !pathContainsNodeModules(info.importingSourceFileName)) { - Debug.type(host); + Debug.assertType(host); // Cache resolutions for all `dependencies` of the `package.json` context of the input file. // This should populate all the relevant symlinks in the symlink cache, and most, if not all, of these resolutions // should get (re)used. diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1f007410f11c5..13ee4eff8a51d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -9,7 +9,6 @@ import { ArrayTypeNode, ArrowFunction, AsExpression, - AssertionLevel, AsteriskToken, attachFileToDiagnostics, AwaitExpression, @@ -9898,7 +9897,7 @@ function markAsIntersectingIncrementalChange(node: Node | NodeArray) { namespace IncrementalParser { export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks: boolean): SourceFile { - aggressiveChecks = aggressiveChecks || Debug.shouldAssert(AssertionLevel.Aggressive); + aggressiveChecks = aggressiveChecks || Debug.shouldAssert(Debug.AssertionLevel.Aggressive); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (textChangeRangeIsUnchanged(textChangeRange)) { @@ -10380,7 +10379,7 @@ namespace IncrementalParser { if (textChangeRange) { Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || Debug.shouldAssert(AssertionLevel.VeryAggressive)) { + if (aggressiveChecks || Debug.shouldAssert(Debug.AssertionLevel.VeryAggressive)) { const oldTextPrefix = oldText.substr(0, textChangeRange.span.start); const newTextPrefix = newText.substr(0, textChangeRange.span.start); Debug.assert(oldTextPrefix === newTextPrefix); diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index f0414f26d24db..d6cd664f39ba1 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1,5 +1,4 @@ import { - AssertionLevel, closeFileWatcher, closeFileWatcherOf, combinePaths, @@ -2005,10 +2004,10 @@ if (sys && sys.getEnvironmentVariable) { setCustomPollingValues(sys); Debug.setAssertionLevel( /^development$/i.test(sys.getEnvironmentVariable("NODE_ENV")) - ? AssertionLevel.Normal - : AssertionLevel.None, + ? Debug.AssertionLevel.Normal + : Debug.AssertionLevel.None, ); } if (sys && sys.debugMode) { - Debug.isDebugging = true; + Debug.setIsDebugging(true); } diff --git a/src/compiler/transformers/declarations/diagnostics.ts b/src/compiler/transformers/declarations/diagnostics.ts index 7e2978d9c59b8..1c0d0afb31359 100644 --- a/src/compiler/transformers/declarations/diagnostics.ts +++ b/src/compiler/transformers/declarations/diagnostics.ts @@ -669,7 +669,7 @@ export function createGetIsolatedDeclarationErrors(resolver: EmitResolver): (nod if ((isPartOfTypeNode(node) || isTypeQueryNode(node.parent)) && (isEntityName(node) || isEntityNameExpression(node))) { return createEntityInTypeNodeError(node); } - Debug.type(node); + Debug.assertType(node); switch (node.kind) { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c7ade289737ca..66ddce638ff05 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2083,7 +2083,7 @@ export function isBlockScope(node: Node, parentNode: Node | undefined): boolean /** @internal */ export function isDeclarationWithTypeParameters(node: Node): node is DeclarationWithTypeParameters { - Debug.type(node); + Debug.assertType(node); switch (node.kind) { case SyntaxKind.JSDocCallbackTag: case SyntaxKind.JSDocTypedefTag: @@ -2097,7 +2097,7 @@ export function isDeclarationWithTypeParameters(node: Node): node is Declaration /** @internal */ export function isDeclarationWithTypeParameterChildren(node: Node): node is DeclarationWithTypeParameterChildren { - Debug.type(node); + Debug.assertType(node); switch (node.kind) { case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: @@ -11798,7 +11798,7 @@ export function createNameResolver({ /** @internal */ export function isPrimitiveLiteralValue(node: Expression, includeBigInt = true): node is PrimitiveLiteral { - Debug.type(node); + Debug.assertType(node); switch (node.kind) { case SyntaxKind.TrueKeyword: case SyntaxKind.FalseKeyword: @@ -11832,7 +11832,7 @@ export function unwrapParenthesizedExpression(o: Expression): Expression { /** @internal */ export function hasInferredType(node: Node): node is HasInferredType { - Debug.type(node); + Debug.assertType(node); switch (node.kind) { case SyntaxKind.Parameter: case SyntaxKind.PropertySignature: diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 1a9e6ed5b920f..c610e072f271b 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1,7 +1,6 @@ import { addToSeen, arrayFrom, - AssertionLevel, CachedDirectoryStructureHost, canJsonReportNoInputFiles, canWatchDirectoryOrFilePath, @@ -2057,7 +2056,7 @@ export class ProjectService { project.print(/*writeProjectFileNames*/ true, /*writeFileExplaination*/ true, /*writeFileVersionAndText*/ false); project.close(); - if (Debug.shouldAssert(AssertionLevel.Normal)) { + if (Debug.shouldAssert(Debug.AssertionLevel.Normal)) { this.filenameToScriptInfo.forEach(info => Debug.assert( !info.isAttached(project), diff --git a/src/testRunner/runner.ts b/src/testRunner/runner.ts index f33b71114e110..3c30a78534510 100644 --- a/src/testRunner/runner.ts +++ b/src/testRunner/runner.ts @@ -228,11 +228,11 @@ function handleTestConfig() { } function beginTests() { - ts.Debug.loggingHost = { + ts.Debug.setLoggingHost({ log(_level, s) { console.log(s || ""); }, - }; + }); if (ts.Debug.isDebugging) { ts.Debug.enableDebugInfo(); diff --git a/src/testRunner/unittests/debugDeprecation.ts b/src/testRunner/unittests/debugDeprecation.ts index 09cc781114780..76d8544718eae 100644 --- a/src/testRunner/unittests/debugDeprecation.ts +++ b/src/testRunner/unittests/debugDeprecation.ts @@ -2,12 +2,12 @@ import { deprecate } from "../../deprecatedCompat/deprecate.js"; import * as ts from "../_namespaces/ts.js"; describe("unittests:: debugDeprecation", () => { - let loggingHost: ts.LoggingHost | undefined; + let loggingHost: ts.Debug.LoggingHost | undefined; beforeEach(() => { loggingHost = ts.Debug.loggingHost; }); afterEach(() => { - ts.Debug.loggingHost = loggingHost; + ts.Debug.setLoggingHost(loggingHost); loggingHost = undefined; }); describe("deprecateFunction", () => { @@ -17,11 +17,11 @@ describe("unittests:: debugDeprecation", () => { typeScriptVersion: "3.8", }); let logWritten = false; - ts.Debug.loggingHost = { + ts.Debug.setLoggingHost({ log() { logWritten = true; }, - }; + }); deprecation(); assert.isFalse(logWritten); }); @@ -31,11 +31,11 @@ describe("unittests:: debugDeprecation", () => { typeScriptVersion: "3.9", }); let logWritten = false; - ts.Debug.loggingHost = { + ts.Debug.setLoggingHost({ log() { logWritten = true; }, - }; + }); deprecation(); assert.isTrue(logWritten); }); @@ -44,11 +44,11 @@ describe("unittests:: debugDeprecation", () => { typeScriptVersion: "3.9", }); let logWritten = false; - ts.Debug.loggingHost = { + ts.Debug.setLoggingHost({ log() { logWritten = true; }, - }; + }); deprecation(); assert.isTrue(logWritten); }); @@ -57,11 +57,11 @@ describe("unittests:: debugDeprecation", () => { typeScriptVersion: "3.9", }); let logWrites = 0; - ts.Debug.loggingHost = { + ts.Debug.setLoggingHost({ log() { logWrites++; }, - }; + }); deprecation(); deprecation(); assert.equal(logWrites, 1); @@ -73,11 +73,11 @@ describe("unittests:: debugDeprecation", () => { typeScriptVersion: "3.9", }); let logWritten = false; - ts.Debug.loggingHost = { + ts.Debug.setLoggingHost({ log() { logWritten = true; }, - }; + }); expect(deprecation).throws(); assert.isFalse(logWritten); }); @@ -86,11 +86,11 @@ describe("unittests:: debugDeprecation", () => { error: true, }); let logWritten = false; - ts.Debug.loggingHost = { + ts.Debug.setLoggingHost({ log() { logWritten = true; }, - }; + }); expect(deprecation).throws(); assert.isFalse(logWritten); }); diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index f3f22307e3e67..a87008d2766cd 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -3,11 +3,11 @@ import * as ts from "./_namespaces/ts.js"; // This file actually uses arguments passed on commandline and executes it // enable deprecation logging -ts.Debug.loggingHost = { +ts.Debug.setLoggingHost({ log(_level, s) { ts.sys.write(`${s || ""}${ts.sys.newLine}`); }, -}; +}); if (ts.Debug.isDebugging) { ts.Debug.enableDebugInfo(); diff --git a/src/tsserver/nodeServer.ts b/src/tsserver/nodeServer.ts index 376caaa0e6ae8..df1cab9125745 100644 --- a/src/tsserver/nodeServer.ts +++ b/src/tsserver/nodeServer.ts @@ -197,18 +197,18 @@ export function initializeNodeSystem(): StartInput { const logger = createLogger(); // enable deprecation logging - Debug.loggingHost = { + Debug.setLoggingHost({ log(level, s) { switch (level) { - case ts.LogLevel.Error: - case ts.LogLevel.Warning: + case ts.Debug.LogLevel.Error: + case ts.Debug.LogLevel.Warning: return logger.msg(s, ts.server.Msg.Err); - case ts.LogLevel.Info: - case ts.LogLevel.Verbose: + case ts.Debug.LogLevel.Info: + case ts.Debug.LogLevel.Verbose: return logger.msg(s, ts.server.Msg.Info); } }, - }; + }); const pending = createQueue(); let canWrite = true; diff --git a/src/typescript/typescript.ts b/src/typescript/typescript.ts index 9e54bbe9c15b0..c3ce1bd27bce4 100644 --- a/src/typescript/typescript.ts +++ b/src/typescript/typescript.ts @@ -1,25 +1,22 @@ -import { - Debug, - LogLevel, -} from "./_namespaces/ts.js"; +import { Debug } from "./_namespaces/ts.js"; // enable deprecation logging declare const console: any; if (typeof console !== "undefined") { - Debug.loggingHost = { + Debug.setLoggingHost({ log(level, s) { switch (level) { - case LogLevel.Error: + case Debug.LogLevel.Error: return console.error(s); - case LogLevel.Warning: + case Debug.LogLevel.Warning: return console.warn(s); - case LogLevel.Info: + case Debug.LogLevel.Info: return console.log(s); - case LogLevel.Verbose: + case Debug.LogLevel.Verbose: return console.log(s); } }, - }; + }); } export * from "./_namespaces/ts.js"; From c9a5de6a6507ba60fd012d30cb03651fafe9ce3c Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:47:09 -0700 Subject: [PATCH 2/3] knipignore --- src/compiler/core.ts | 2 +- src/compiler/debug.ts | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ef83fefd533e0..6070bab46b029 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1917,7 +1917,7 @@ export function memoizeOne(c }; } -/** @internal */ +/** @internal @knipignore */ export const enum AssertionLevel { None = 0, Normal = 1, diff --git a/src/compiler/debug.ts b/src/compiler/debug.ts index f4960e1ded7ff..0c26315746b8a 100644 --- a/src/compiler/debug.ts +++ b/src/compiler/debug.ts @@ -115,10 +115,10 @@ export const enum AssertionLevel { let currentAssertionLevel = AssertionLevel.None; -/** @internal */ +/** @internal @knipignore */ export let currentLogLevel: LogLevel = LogLevel.Warning; -/** @internal */ +/** @internal @knipignore */ export function setCurrentLogLevel(newCurrentLogLevel: LogLevel): void { currentLogLevel = newCurrentLogLevel; } @@ -139,7 +139,7 @@ export function setLoggingHost(newLoggingHost: LoggingHost | undefined): void { loggingHost = newLoggingHost; } -/** @internal */ +/** @internal @knipignore */ export function shouldLog(level: LogLevel): boolean { return currentLogLevel <= level; } @@ -174,7 +174,7 @@ export namespace log { } } -/** @internal */ +/** @internal @knipignore */ export function getAssertionLevel(): AssertionLevel { return currentAssertionLevel; } @@ -352,11 +352,11 @@ export function assertOptionalNode(node: Node | undefined, test: ((node: Node) = } } -/** @internal */ +/** @internal @knipignore */ export function assertOptionalToken(node: T, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract; -/** @internal */ +/** @internal @knipignore */ export function assertOptionalToken(node: T | undefined, kind: K, message?: string, stackCrawlMark?: AnyFunction): asserts node is Extract | undefined; -/** @internal */ +/** @internal @knipignore */ export function assertOptionalToken(node: Node | undefined, kind: SyntaxKind | undefined, message?: string, stackCrawlMark?: AnyFunction): void; export function assertOptionalToken(node: Node | undefined, kind: SyntaxKind | undefined, message?: string, stackCrawlMark?: AnyFunction) { if (shouldAssert(AssertionLevel.Normal)) { @@ -476,7 +476,7 @@ export function formatSyntaxKind(kind: SyntaxKind | undefined): string { return formatEnum(kind, (ts as any).SyntaxKind, /*isFlags*/ false); } -/** @internal */ +/** @internal @knipignore */ export function formatSnippetKind(kind: SnippetKind | undefined): string { return formatEnum(kind, (ts as any).SnippetKind, /*isFlags*/ false); } @@ -496,17 +496,17 @@ export function formatNodeCheckFlags(flags: NodeCheckFlags | undefined): string return formatEnum(flags, (ts as any).NodeCheckFlags, /*isFlags*/ true); } -/** @internal */ +/** @internal @knipignore */ export function formatModifierFlags(flags: ModifierFlags | undefined): string { return formatEnum(flags, (ts as any).ModifierFlags, /*isFlags*/ true); } -/** @internal */ +/** @internal @knipignore */ export function formatTransformFlags(flags: TransformFlags | undefined): string { return formatEnum(flags, (ts as any).TransformFlags, /*isFlags*/ true); } -/** @internal */ +/** @internal @knipignore */ export function formatEmitFlags(flags: EmitFlags | undefined): string { return formatEnum(flags, (ts as any).EmitFlags, /*isFlags*/ true); } @@ -521,7 +521,7 @@ export function formatTypeFlags(flags: TypeFlags | undefined): string { return formatEnum(flags, (ts as any).TypeFlags, /*isFlags*/ true); } -/** @internal */ +/** @internal @knipignore */ export function formatSignatureFlags(flags: SignatureFlags | undefined): string { return formatEnum(flags, (ts as any).SignatureFlags, /*isFlags*/ true); } @@ -531,27 +531,27 @@ export function formatObjectFlags(flags: ObjectFlags | undefined): string { return formatEnum(flags, (ts as any).ObjectFlags, /*isFlags*/ true); } -/** @internal */ +/** @internal @knipignore */ export function formatFlowFlags(flags: FlowFlags | undefined): string { return formatEnum(flags, (ts as any).FlowFlags, /*isFlags*/ true); } -/** @internal */ +/** @internal @knipignore */ export function formatRelationComparisonResult(result: RelationComparisonResult | undefined): string { return formatEnum(result, (ts as any).RelationComparisonResult, /*isFlags*/ true); } -/** @internal */ +/** @internal @knipignore */ export function formatCheckMode(mode: CheckMode | undefined): string { return formatEnum(mode, (ts as any).CheckMode, /*isFlags*/ true); } -/** @internal */ +/** @internal @knipignore */ export function formatSignatureCheckMode(mode: SignatureCheckMode | undefined): string { return formatEnum(mode, (ts as any).SignatureCheckMode, /*isFlags*/ true); } -/** @internal */ +/** @internal @knipignore */ export function formatTypeFacts(facts: TypeFacts | undefined): string { return formatEnum(facts, (ts as any).TypeFacts, /*isFlags*/ true); } @@ -876,7 +876,7 @@ export function formatVariance(varianceFlags: VarianceFlags): string { /** @internal */ export type DebugType = Type & { __debugTypeToString(): string; }; // eslint-disable-line @typescript-eslint/naming-convention -/** @internal */ +/** @internal @knipignore */ export class DebugTypeMapper { declare kind: TypeMapKind; __debugToString(): string { // eslint-disable-line @typescript-eslint/naming-convention @@ -916,12 +916,12 @@ export function attachDebugPrototypeIfDebug(mapper: TypeMapper): TypeMapper { return mapper; } -/** @internal */ +/** @internal @knipignore */ export function printControlFlowGraph(flowNode: FlowNode): void { return console.log(formatControlFlowGraph(flowNode)); } -/** @internal */ +/** @internal @knipignore */ export function formatControlFlowGraph(flowNode: FlowNode): string { let nextDebugFlowId = -1; From 9cb279e8b647b18bb313e63b1cf9bdbbb2c4caf0 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:35:38 -0700 Subject: [PATCH 3/3] Fix all except special entrypoints and tests --- src/compiler/binder.ts | 2 +- src/compiler/builder.ts | 2 +- src/compiler/builderState.ts | 2 +- src/compiler/checker.ts | 2 +- src/compiler/commandLineParser.ts | 2 +- src/compiler/core.ts | 2 +- src/compiler/emitter.ts | 2 +- src/compiler/executeCommandLine.ts | 2 +- src/compiler/expressionToTypeNode.ts | 2 +- src/compiler/factory/emitHelpers.ts | 2 +- src/compiler/factory/emitNode.ts | 2 +- src/compiler/factory/nodeChildren.ts | 2 +- src/compiler/factory/nodeConverters.ts | 2 +- src/compiler/factory/nodeFactory.ts | 2 +- src/compiler/factory/utilities.ts | 2 +- src/compiler/moduleNameResolver.ts | 2 +- src/compiler/moduleSpecifiers.ts | 2 +- src/compiler/parser.ts | 2 +- src/compiler/path.ts | 2 +- src/compiler/performance.ts | 2 +- src/compiler/program.ts | 2 +- src/compiler/resolutionCache.ts | 2 +- src/compiler/scanner.ts | 2 +- src/compiler/semver.ts | 2 +- src/compiler/sourcemap.ts | 2 +- src/compiler/sys.ts | 2 +- src/compiler/tracing.ts | 2 +- src/compiler/transformer.ts | 2 +- src/compiler/transformers/classFields.ts | 2 +- src/compiler/transformers/declarations.ts | 2 +- src/compiler/transformers/declarations/diagnostics.ts | 2 +- src/compiler/transformers/destructuring.ts | 2 +- src/compiler/transformers/es2015.ts | 2 +- src/compiler/transformers/es2017.ts | 2 +- src/compiler/transformers/es2018.ts | 2 +- src/compiler/transformers/es2020.ts | 2 +- src/compiler/transformers/esDecorators.ts | 2 +- src/compiler/transformers/esnext.ts | 2 +- src/compiler/transformers/generators.ts | 2 +- src/compiler/transformers/jsx.ts | 2 +- src/compiler/transformers/legacyDecorators.ts | 2 +- src/compiler/transformers/module/esnextAnd2015.ts | 2 +- .../transformers/module/impliedNodeFormatDependent.ts | 2 +- src/compiler/transformers/module/module.ts | 2 +- src/compiler/transformers/module/system.ts | 2 +- src/compiler/transformers/taggedTemplate.ts | 2 +- src/compiler/transformers/ts.ts | 2 +- src/compiler/transformers/typeSerializer.ts | 2 +- src/compiler/tsbuildPublic.ts | 2 +- src/compiler/utilities.ts | 2 +- src/compiler/utilitiesPublic.ts | 2 +- src/compiler/visitorPublic.ts | 2 +- src/compiler/watch.ts | 2 +- src/compiler/watchPublic.ts | 2 +- src/compiler/watchUtilities.ts | 2 +- src/deprecatedCompat/deprecate.ts | 2 +- src/jsTyping/jsTyping.ts | 2 +- src/server/editorServices.ts | 2 +- src/server/moduleSpecifierCache.ts | 2 +- src/server/packageJsonCache.ts | 2 +- src/server/project.ts | 2 +- src/server/scriptInfo.ts | 2 +- src/server/scriptVersionCache.ts | 2 +- src/server/session.ts | 2 +- src/server/typingInstallerAdapter.ts | 2 +- src/services/breakpoints.ts | 2 +- src/services/callHierarchy.ts | 2 +- src/services/classifier.ts | 2 +- src/services/classifier2020.ts | 2 +- src/services/codeFixProvider.ts | 2 +- src/services/codefixes/addMissingInvocationForDecorator.ts | 2 +- .../codefixes/addMissingResolutionModeImportAttribute.ts | 2 +- src/services/codefixes/addNameToNamelessParameter.ts | 2 +- src/services/codefixes/annotateWithTypeFromJSDoc.ts | 2 +- src/services/codefixes/convertToAsyncFunction.ts | 2 +- src/services/codefixes/convertToEsModule.ts | 2 +- .../codefixes/correctQualifiedNameToIndexedAccessType.ts | 2 +- src/services/codefixes/fixAddMissingMember.ts | 2 +- .../codefixes/fixAddModuleReferTypeMissingTypeof.ts | 2 +- src/services/codefixes/fixCannotFindModule.ts | 2 +- .../codefixes/fixClassIncorrectlyImplementsInterface.ts | 2 +- .../codefixes/fixConstructorForDerivedNeedSuperCall.ts | 2 +- src/services/codefixes/fixImplicitThis.ts | 2 +- .../codefixes/fixMissingTypeAnnotationOnExports.ts | 2 +- src/services/codefixes/fixOverrideModifier.ts | 2 +- src/services/codefixes/fixPropertyOverrideAccessor.ts | 2 +- src/services/codefixes/fixSpelling.ts | 2 +- src/services/codefixes/fixStrictClassInitialization.ts | 2 +- src/services/codefixes/fixUnreachableCode.ts | 2 +- src/services/codefixes/fixUnusedIdentifier.ts | 2 +- src/services/codefixes/helpers.ts | 2 +- src/services/codefixes/importFixes.ts | 2 +- src/services/codefixes/inferFromUsage.ts | 2 +- src/services/codefixes/requireInTs.ts | 2 +- src/services/codefixes/returnValueCorrect.ts | 2 +- src/services/codefixes/splitTypeOnlyImport.ts | 2 +- src/services/codefixes/wrapDecoratorInParentheses.ts | 2 +- src/services/completions.ts | 2 +- src/services/documentHighlights.ts | 2 +- src/services/documentRegistry.ts | 2 +- src/services/exportInfoMap.ts | 2 +- src/services/findAllReferences.ts | 2 +- src/services/formatting/formatting.ts | 2 +- src/services/formatting/formattingContext.ts | 2 +- src/services/formatting/formattingScanner.ts | 2 +- src/services/formatting/rulesMap.ts | 2 +- src/services/formatting/smartIndenter.ts | 2 +- src/services/getEditsForFileRename.ts | 2 +- src/services/importTracker.ts | 2 +- src/services/inlayHints.ts | 2 +- src/services/navigationBar.ts | 2 +- src/services/outliningElementsCollector.ts | 2 +- src/services/pasteEdits.ts | 2 +- src/services/refactors/addOrRemoveBracesToArrowFunction.ts | 2 +- .../refactors/convertArrowFunctionOrFunctionExpression.ts | 2 +- src/services/refactors/convertExport.ts | 2 +- src/services/refactors/convertImport.ts | 2 +- .../refactors/convertOverloadListToSingleSignature.ts | 2 +- .../refactors/convertParamsToDestructuredObject.ts | 2 +- src/services/refactors/convertStringOrTemplateLiteral.ts | 2 +- src/services/refactors/convertToOptionalChainExpression.ts | 2 +- src/services/refactors/extractSymbol.ts | 2 +- src/services/refactors/extractType.ts | 2 +- .../refactors/generateGetAccessorAndSetAccessor.ts | 2 +- src/services/refactors/helpers.ts | 2 +- src/services/refactors/inlineVariable.ts | 2 +- src/services/refactors/moveToFile.ts | 2 +- src/services/refactors/moveToNewFile.ts | 2 +- src/services/services.ts | 2 +- src/services/signatureHelp.ts | 2 +- src/services/smartSelection.ts | 2 +- src/services/stringCompletions.ts | 2 +- src/services/symbolDisplay.ts | 2 +- src/services/textChanges.ts | 2 +- src/services/transpile.ts | 2 +- src/services/utilities.ts | 2 +- src/tsc/tsc.ts | 7 ++++--- src/typescript/typescript.ts | 2 +- src/typingsInstallerCore/typingsInstaller.ts | 2 +- 139 files changed, 142 insertions(+), 141 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7f61986a80fb8..4bd3906db5dc4 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -39,7 +39,6 @@ import { createFileDiagnostic, createQueue, createSymbolTable, - Debug, Declaration, declarationNameToString, DeleteExpression, @@ -321,6 +320,7 @@ import { WithStatement, } from "./_namespaces/ts.js"; import * as performance from "./_namespaces/ts.performance.js"; +import * as Debug from "./debug.js"; /** @internal */ export const enum ModuleInstanceState { diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 1c472cebead0d..8df910376ce63 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -26,7 +26,6 @@ import { createModuleNotFoundChain, createProgram, CustomTransformers, - Debug, Diagnostic, DiagnosticCategory, DiagnosticMessageChain, @@ -90,6 +89,7 @@ import { WriteFileCallback, WriteFileCallbackData, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** @internal */ export interface ReusableDiagnostic extends ReusableDiagnosticRelatedInformation { diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index cf9932e94631b..62259021a040d 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -4,7 +4,6 @@ import { CompilerOptions, computeSignatureWithDiagnostics, CustomTransformers, - Debug, EmitOnly, EmitOutput, emptyArray, @@ -34,6 +33,7 @@ import { toPath, TypeChecker, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** @internal */ export function getFileEmitOutput( diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 438e46eca11b6..40080650ee23d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -130,7 +130,6 @@ import { createSymbolTable, createSyntacticTypeNodeBuilder, createTextWriter, - Debug, Declaration, DeclarationName, declarationNameToString, @@ -1124,6 +1123,7 @@ import { } from "./_namespaces/ts.js"; import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers.js"; import * as performance from "./_namespaces/ts.performance.js"; +import * as Debug from "./debug.js"; const ambientModuleSymbolRegex = /^".+"$/; const anon = "(anonymous)" as __String & string; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 830fb26370426..c709feaaa00e1 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -22,7 +22,6 @@ import { createCompilerDiagnostic, createDiagnosticForNodeInSourceFile, createGetCanonicalFileName, - Debug, Diagnostic, DiagnosticArguments, DiagnosticMessage, @@ -122,6 +121,7 @@ import { WatchFileKind, WatchOptions, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 6070bab46b029..7ccddb9ecb12b 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2,7 +2,6 @@ import { CharacterCodes, Comparer, Comparison, - Debug, EqualityComparer, MapLike, Queue, @@ -10,6 +9,7 @@ import { SortedReadonlyArray, TextSpan, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /* eslint-disable @typescript-eslint/prefer-for-of */ diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index e63bfd783ced2..3da1b200582db 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -54,7 +54,6 @@ import { createGetCanonicalFileName, createSourceMapGenerator, createTextWriter, - Debug, DebuggerStatement, DeclarationName, Decorator, @@ -424,6 +423,7 @@ import { YieldExpression, } from "./_namespaces/ts.js"; import * as performance from "./_namespaces/ts.performance.js"; +import * as Debug from "./debug.js"; const brackets = createBracketsMap(); diff --git a/src/compiler/executeCommandLine.ts b/src/compiler/executeCommandLine.ts index ca166635ac5c1..488a34ef779c9 100644 --- a/src/compiler/executeCommandLine.ts +++ b/src/compiler/executeCommandLine.ts @@ -29,7 +29,6 @@ import { createWatchCompilerHostOfFilesAndCompilerOptions, createWatchProgram, createWatchStatusReporter as ts_createWatchStatusReporter, - Debug, Diagnostic, DiagnosticMessage, DiagnosticReporter, @@ -88,6 +87,7 @@ import { WatchOfConfigFile, WatchOptions, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; import * as performance from "./performance.js"; interface Statistic { diff --git a/src/compiler/expressionToTypeNode.ts b/src/compiler/expressionToTypeNode.ts index 1c6e045f0f0bd..737d95533ac92 100644 --- a/src/compiler/expressionToTypeNode.ts +++ b/src/compiler/expressionToTypeNode.ts @@ -8,7 +8,6 @@ import { BindingElement, ClassExpression, CompilerOptions, - Debug, ElementAccessExpression, ExportAssignment, Expression, @@ -65,6 +64,7 @@ import { UnionTypeNode, VariableDeclaration, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** @internal */ export function createSyntacticTypeNodeBuilder( diff --git a/src/compiler/factory/emitHelpers.ts b/src/compiler/factory/emitHelpers.ts index 722e408e0743b..dc0bb819133a8 100644 --- a/src/compiler/factory/emitHelpers.ts +++ b/src/compiler/factory/emitHelpers.ts @@ -6,7 +6,6 @@ import { compareValues, Comparison, createExpressionFromEntityName, - Debug, EmitFlags, EmitHelper, EmitHelperUniqueNameCallback, @@ -36,6 +35,7 @@ import { TransformationContext, UnscopedEmitHelper, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** @internal */ export const enum PrivateIdentifierKind { diff --git a/src/compiler/factory/emitNode.ts b/src/compiler/factory/emitNode.ts index beadc29d4ca6b..71512918baf37 100644 --- a/src/compiler/factory/emitNode.ts +++ b/src/compiler/factory/emitNode.ts @@ -3,7 +3,6 @@ import { append, appendIfUnique, AutoGenerateInfo, - Debug, EmitFlags, EmitHelper, EmitNode, @@ -27,6 +26,7 @@ import { TypeNode, TypeParameterDeclaration, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** * Associates a node with the current transformation, initializing diff --git a/src/compiler/factory/nodeChildren.ts b/src/compiler/factory/nodeChildren.ts index da8e074415e00..91d1092506f3c 100644 --- a/src/compiler/factory/nodeChildren.ts +++ b/src/compiler/factory/nodeChildren.ts @@ -1,5 +1,4 @@ import { - Debug, emptyArray, isNodeKind, Node, @@ -7,6 +6,7 @@ import { SyntaxKind, SyntaxList, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; const sourceFileToNodeChildren = new WeakMap>(); diff --git a/src/compiler/factory/nodeConverters.ts b/src/compiler/factory/nodeConverters.ts index 14ef80f2ae379..26c16411896e6 100644 --- a/src/compiler/factory/nodeConverters.ts +++ b/src/compiler/factory/nodeConverters.ts @@ -8,7 +8,6 @@ import { cast, ClassDeclaration, ConciseBody, - Debug, Expression, FunctionDeclaration, getModifiers, @@ -36,6 +35,7 @@ import { setTextRange, SyntaxKind, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** @internal */ export function createNodeConverters(factory: NodeFactory): NodeConverters { diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index fbc97d9aa4d9c..a5ebe5d972e7b 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -59,7 +59,6 @@ import { createNodeConverters, createParenthesizerRules, createScanner, - Debug, DebuggerStatement, Declaration, DeclarationName, @@ -458,6 +457,7 @@ import { WithStatement, YieldExpression, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; let nextAutoGenerateId = 0; diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 5261459afc862..42865c8cff268 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -21,7 +21,6 @@ import { compareStringsCaseSensitive, CompilerOptions, ComputedPropertyName, - Debug, Declaration, DefaultKeyword, EmitFlags, @@ -175,6 +174,7 @@ import { UnscopedEmitHelper, WrappedExpression, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; // Compound nodes diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index aedc7beca8c47..5d02a5fb2d256 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -15,7 +15,6 @@ import { contains, containsPath, createCompilerDiagnostic, - Debug, deduplicate, Diagnostic, DiagnosticMessage, @@ -109,6 +108,7 @@ import { versionMajorMinor, VersionRange, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** @internal */ export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void { diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index caf36f7bd5a37..bfa651be31d00 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -16,7 +16,6 @@ import { containsIgnoredPath, containsPath, createGetCanonicalFileName, - Debug, directorySeparator, emptyArray, endsWith, @@ -129,6 +128,7 @@ import { TypeChecker, UserPreferences, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; const stringToRegex = memoizeOne((pattern: string) => { try { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 13ee4eff8a51d..a0d54a4f364d7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -56,7 +56,6 @@ import { createScanner, createTextChangeRange, createTextSpanFromBounds, - Debug, Decorator, DefaultClause, DeleteExpression, @@ -399,6 +398,7 @@ import { YieldExpression, } from "./_namespaces/ts.js"; import * as performance from "./_namespaces/ts.performance.js"; +import * as Debug from "./debug.js"; const enum SignatureFlags { None = 0, diff --git a/src/compiler/path.ts b/src/compiler/path.ts index b05216adc47b5..3c0f7df30cd1a 100644 --- a/src/compiler/path.ts +++ b/src/compiler/path.ts @@ -4,7 +4,6 @@ import { compareStringsCaseSensitive, compareValues, Comparison, - Debug, endsWith, equateStringsCaseInsensitive, equateStringsCaseSensitive, @@ -17,6 +16,7 @@ import { some, startsWith, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** * Internally, we represent paths as strings with '/' as the directory separator. diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index e176474b37ba8..ee325c200c607 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -1,5 +1,4 @@ import { - Debug, noop, Performance, PerformanceHooks, @@ -8,6 +7,7 @@ import { timestamp, tryGetNativePerformanceHooks, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** Performance measurements for the compiler. */ diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ad18f43b29e35..77b076ab22a10 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -52,7 +52,6 @@ import { createTypeChecker, createTypeReferenceDirectiveResolutionCache, CustomTransformers, - Debug, DeclarationWithTypeParameterChildren, Diagnostic, DiagnosticArguments, @@ -335,6 +334,7 @@ import { writeFileEnsuringDirectories, } from "./_namespaces/ts.js"; import * as performance from "./_namespaces/ts.performance.js"; +import * as Debug from "./debug.js"; export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string | undefined { return forEachAncestorDirectory(searchPath, ancestor => { diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 7c69055ec1f66..af6112952b756 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -8,7 +8,6 @@ import { createModuleResolutionCache, createTypeReferenceDirectiveResolutionCache, createTypeReferenceResolutionLoader, - Debug, Diagnostics, directorySeparator, DirectoryWatcherCallback, @@ -76,6 +75,7 @@ import { updateResolutionField, WatchDirectoryFlags, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** @internal */ export interface HasInvalidatedFromResolutionCache { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 50e827c17bd24..7b7fc092012ef 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -8,7 +8,6 @@ import { CommentKind, CommentRange, compareValues, - Debug, DiagnosticMessage, Diagnostics, forEach, @@ -35,6 +34,7 @@ import { TextRange, TokenFlags, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; export type ErrorCallback = (message: DiagnosticMessage, length: number, arg0?: any) => void; diff --git a/src/compiler/semver.ts b/src/compiler/semver.ts index f9423d77f5232..074758c4ad9ca 100644 --- a/src/compiler/semver.ts +++ b/src/compiler/semver.ts @@ -2,13 +2,13 @@ import { compareStringsCaseSensitive, compareValues, Comparison, - Debug, emptyArray, every, isArray, map, some, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 1ce989b250af7..b16f213bff371 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -4,7 +4,6 @@ import { CharacterCodes, combinePaths, compareValues, - Debug, DocumentPosition, DocumentPositionMapper, DocumentPositionMapperHost, @@ -26,6 +25,7 @@ import { SourceMapGenerator, } from "./_namespaces/ts.js"; import * as performance from "./_namespaces/ts.performance.js"; +import * as Debug from "./debug.js"; /** @internal */ export interface SourceMapGeneratorOptions { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index d6cd664f39ba1..72d5ecac7c456 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -7,7 +7,6 @@ import { containsPath, createGetCanonicalFileName, createMultiMap, - Debug, directorySeparator, emptyArray, emptyFileSystemEntries, @@ -45,6 +44,7 @@ import { WatchOptions, writeFileEnsuringDirectories, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; diff --git a/src/compiler/tracing.ts b/src/compiler/tracing.ts index 5d7138d1c22eb..c0b3683dd23a6 100644 --- a/src/compiler/tracing.ts +++ b/src/compiler/tracing.ts @@ -1,7 +1,6 @@ import { combinePaths, ConditionalType, - Debug, EvolvingArrayType, getLineAndCharacterOfPosition, getSourceFileOfNode, @@ -22,6 +21,7 @@ import { UnionType, } from "./_namespaces/ts.js"; import * as performance from "./_namespaces/ts.performance.js"; +import * as Debug from "./debug.js"; /* Tracing events for the compiler. */ diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 0d499f3a08298..d697bb5dc581a 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -8,7 +8,6 @@ import { CustomTransformer, CustomTransformerFactory, CustomTransformers, - Debug, DiagnosticWithLocation, disposeEmitNodes, EmitFlags, @@ -74,6 +73,7 @@ import { VariableDeclaration, } from "./_namespaces/ts.js"; import * as performance from "./_namespaces/ts.performance.js"; +import * as Debug from "./debug.js"; function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory { switch (moduleKind) { diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index 7d8bc6f8eab22..779bf2f590ea2 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -33,7 +33,6 @@ import { createAccessorPropertyGetRedirector, createAccessorPropertySetRedirector, createMemberAccessForPropertyName, - Debug, ElementAccessExpression, EmitFlags, EmitHint, @@ -226,6 +225,7 @@ import { visitParameterList, VisitResult, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; const enum ClassPropertySubstitutionFlags { None = 0, diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index ba19f34fe0af9..8eacebc729151 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -25,7 +25,6 @@ import { createGetSymbolAccessibilityDiagnosticForNode, createGetSymbolAccessibilityDiagnosticForNodeName, createSymbolTable, - Debug, Declaration, DeclarationDiagnosticProducing, DeclarationName, @@ -214,6 +213,7 @@ import { visitNodes, VisitResult, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** @internal */ export function getDeclarationDiagnostics( diff --git a/src/compiler/transformers/declarations/diagnostics.ts b/src/compiler/transformers/declarations/diagnostics.ts index 1c0d0afb31359..61ee3a826585b 100644 --- a/src/compiler/transformers/declarations/diagnostics.ts +++ b/src/compiler/transformers/declarations/diagnostics.ts @@ -11,7 +11,6 @@ import { ConstructorDeclaration, ConstructSignatureDeclaration, createDiagnosticForNode, - Debug, Declaration, DeclarationName, DiagnosticMessage, @@ -96,6 +95,7 @@ import { TypeParameterDeclaration, VariableDeclaration, } from "../../_namespaces/ts.js"; +import * as Debug from "../../debug.js"; /** @internal */ export type GetSymbolAccessibilityDiagnostic = (symbolAccessibilityResult: SymbolAccessibilityResult) => SymbolAccessibilityDiagnostic | undefined; diff --git a/src/compiler/transformers/destructuring.ts b/src/compiler/transformers/destructuring.ts index cca1f2b9e6fba..11e166fe7859b 100644 --- a/src/compiler/transformers/destructuring.ts +++ b/src/compiler/transformers/destructuring.ts @@ -7,7 +7,6 @@ import { BindingOrAssignmentElement, BindingOrAssignmentElementTarget, BindingOrAssignmentPattern, - Debug, DestructuringAssignment, ElementAccessExpression, every, @@ -62,6 +61,7 @@ import { visitNode, VisitResult, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; interface FlattenContext { context: TransformationContext; diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 5b29d34da9387..7fd48e2d0e069 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -34,7 +34,6 @@ import { createMemberAccessForPropertyName, createRange, createTokenRange, - Debug, Declaration, DoStatement, elementAt, @@ -216,6 +215,7 @@ import { WhileStatement, YieldExpression, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; const enum ES2015SubstitutionFlags { None = 0, diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 3a80a84334eef..af01dc24900f4 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -17,7 +17,6 @@ import { ClassDeclaration, ConciseBody, ConstructorDeclaration, - Debug, ElementAccessExpression, EmitFlags, EmitHint, @@ -100,6 +99,7 @@ import { visitParameterList, VisitResult, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration; diff --git a/src/compiler/transformers/es2018.ts b/src/compiler/transformers/es2018.ts index c8894d336af1c..eaa0eab90d56b 100644 --- a/src/compiler/transformers/es2018.ts +++ b/src/compiler/transformers/es2018.ts @@ -22,7 +22,6 @@ import { containsObjectRestOrSpread, createForOfBindingStatement, createSuperAccessVariableStatement, - Debug, ElementAccessExpression, EmitFlags, EmitHint, @@ -111,6 +110,7 @@ import { VoidExpression, YieldExpression, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; const enum ESNextSubstitutionFlags { None = 0, diff --git a/src/compiler/transformers/es2020.ts b/src/compiler/transformers/es2020.ts index 8d25281d799b7..7374d0d0f0fc4 100644 --- a/src/compiler/transformers/es2020.ts +++ b/src/compiler/transformers/es2020.ts @@ -6,7 +6,6 @@ import { CallExpression, cast, chainBundle, - Debug, DeleteExpression, EmitFlags, Expression, @@ -37,6 +36,7 @@ import { visitNodes, VisitResult, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** @internal */ export function transformES2020(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle { diff --git a/src/compiler/transformers/esDecorators.ts b/src/compiler/transformers/esDecorators.ts index 7609ab957a0c5..6788708c7ff7f 100644 --- a/src/compiler/transformers/esDecorators.ts +++ b/src/compiler/transformers/esDecorators.ts @@ -26,7 +26,6 @@ import { ComputedPropertyName, ConstructorDeclaration, createAccessorPropertyBackingField, - Debug, Decorator, ElementAccessExpression, EmitFlags, @@ -189,6 +188,7 @@ import { VisitResult, WrappedExpression, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; // Class/Decorator evaluation order, as it pertains to this transformer: // diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 4deb7ecbd9a36..979544031075d 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -9,7 +9,6 @@ import { CaseOrDefaultClause, chainBundle, ClassDeclaration, - Debug, EmitFlags, ExportAssignment, ExportSpecifier, @@ -63,6 +62,7 @@ import { visitNodes, VisitResult, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; const enum UsingKind { None, diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 4031cb704665a..902d33c51d8f4 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -15,7 +15,6 @@ import { ConditionalExpression, ContinueStatement, createExpressionForObjectLiteralElementLike, - Debug, DoStatement, ElementAccessExpression, EmitFlags, @@ -96,6 +95,7 @@ import { WithStatement, YieldExpression, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; // Transforms generator functions into a compatible ES5 representation with similar runtime // semantics. This is accomplished by first transforming the body of each generator diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index bcb0cbf8ee2cc..c341e2e59d41a 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -7,7 +7,6 @@ import { createExpressionForJsxFragment, createExpressionFromEntityName, createJsxFactoryExpression, - Debug, emptyArray, Expression, filter, @@ -85,6 +84,7 @@ import { visitNode, VisitResult, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** @internal */ export function transformJsx(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle { diff --git a/src/compiler/transformers/legacyDecorators.ts b/src/compiler/transformers/legacyDecorators.ts index 6ef7745dfd301..50f72eb2b8a77 100644 --- a/src/compiler/transformers/legacyDecorators.ts +++ b/src/compiler/transformers/legacyDecorators.ts @@ -14,7 +14,6 @@ import { ClassLikeDeclaration, classOrConstructorParameterIsDecorated, ConstructorDeclaration, - Debug, Decorator, elideNodes, EmitFlags, @@ -83,6 +82,7 @@ import { visitNodes, VisitResult, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** @internal */ export function transformLegacyDecorators(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle { diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts index f36388bf8983b..958fda06858cf 100644 --- a/src/compiler/transformers/module/esnextAnd2015.ts +++ b/src/compiler/transformers/module/esnextAnd2015.ts @@ -5,7 +5,6 @@ import { chainBundle, createEmptyExports, createExternalHelpersImportDeclarationIfNeeded, - Debug, EmitFlags, EmitHint, ExportAssignment, @@ -54,6 +53,7 @@ import { visitNodes, VisitResult, } from "../../_namespaces/ts.js"; +import * as Debug from "../../debug.js"; /** @internal */ export function transformECMAScriptModule(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle { diff --git a/src/compiler/transformers/module/impliedNodeFormatDependent.ts b/src/compiler/transformers/module/impliedNodeFormatDependent.ts index c793c3abe3c54..af835afb24c19 100644 --- a/src/compiler/transformers/module/impliedNodeFormatDependent.ts +++ b/src/compiler/transformers/module/impliedNodeFormatDependent.ts @@ -1,6 +1,5 @@ import { Bundle, - Debug, EmitHint, isSourceFile, map, @@ -13,6 +12,7 @@ import { Transformer, transformModule, } from "../../_namespaces/ts.js"; +import * as Debug from "../../debug.js"; /** @internal */ export function transformImpliedNodeFormatDependentModule(context: TransformationContext): Transformer { diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index be0cf4bdf85c2..191098bc9a4dd 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -17,7 +17,6 @@ import { chainBundle, ClassDeclaration, collectExternalModuleInfo, - Debug, Declaration, DefaultClause, DestructuringAssignment, @@ -165,6 +164,7 @@ import { WhileStatement, WithStatement, } from "../../_namespaces/ts.js"; +import * as Debug from "../../debug.js"; /** @internal */ export function transformModule(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle { diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index c9fd1645345ca..215a73bface45 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -12,7 +12,6 @@ import { chainBundle, ClassDeclaration, collectExternalModuleInfo, - Debug, Declaration, DefaultClause, DestructuringAssignment, @@ -132,6 +131,7 @@ import { WhileStatement, WithStatement, } from "../../_namespaces/ts.js"; +import * as Debug from "../../debug.js"; /** @internal */ export function transformSystemModule(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle { diff --git a/src/compiler/transformers/taggedTemplate.ts b/src/compiler/transformers/taggedTemplate.ts index 94f01dec4ba5e..9ce60978257dc 100644 --- a/src/compiler/transformers/taggedTemplate.ts +++ b/src/compiler/transformers/taggedTemplate.ts @@ -1,6 +1,5 @@ import { CallExpression, - Debug, Expression, getSourceTextOfNodeFromSourceFile, hasInvalidEscape, @@ -24,6 +23,7 @@ import { visitNode, Visitor, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** @internal */ export enum ProcessLevel { diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 75a6a34a55b1c..406b60d1ae69b 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -25,7 +25,6 @@ import { createRange, createRuntimeTypeSerializer, createTokenRange, - Debug, Declaration, Decorator, ElementAccessExpression, @@ -202,6 +201,7 @@ import { visitParameterList, VisitResult, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** * Indicates whether to emit type metadata in the new format. diff --git a/src/compiler/transformers/typeSerializer.ts b/src/compiler/transformers/typeSerializer.ts index 4c9d397b74385..02ca2d038f72b 100644 --- a/src/compiler/transformers/typeSerializer.ts +++ b/src/compiler/transformers/typeSerializer.ts @@ -8,7 +8,6 @@ import { ClassLikeDeclaration, ConditionalExpression, ConditionalTypeNode, - Debug, EntityName, Expression, findAncestor, @@ -68,6 +67,7 @@ import { UnionOrIntersectionTypeNode, VoidExpression, } from "../_namespaces/ts.js"; +import * as Debug from "../debug.js"; /** @internal */ export type SerializedEntityName = diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index be2074ed22d28..e71a2d46c0b4d 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -30,7 +30,6 @@ import { createWatchFactory, createWatchHost, CustomTransformers, - Debug, Diagnostic, DiagnosticArguments, DiagnosticMessage, @@ -129,6 +128,7 @@ import { WriteFileCallback, } from "./_namespaces/ts.js"; import * as performance from "./_namespaces/ts.performance.js"; +import * as Debug from "./debug.js"; const minimumDate = new Date(-8640000000000000); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 66ddce638ff05..386859d1f2e3c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -84,7 +84,6 @@ import { createScanner, createTextSpan, createTextSpanFromBounds, - Debug, Declaration, DeclarationName, DeclarationWithTypeParameterChildren, @@ -590,6 +589,7 @@ import { WriteFileCallbackData, YieldExpression, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** @internal */ export const resolvingEmptyArray: never[] = []; diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 462ebc6da06d4..b04c505d4484a 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -41,7 +41,6 @@ import { ConstructorTypeNode, contains, createCompilerDiagnostic, - Debug, Declaration, DeclarationName, DeclarationStatement, @@ -291,6 +290,7 @@ import { UnaryExpression, VariableDeclaration, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; export function isExternalModuleNameRelative(moduleName: string): boolean { // TypeScript 1.0 spec (April 2014): 11.2.1 diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index dbd49379e5750..b0df35ef6b726 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -1,6 +1,5 @@ import { ConciseBody, - Debug, EmitFlags, Expression, factory, @@ -104,6 +103,7 @@ import { TransformationContext, Visitor, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index a859bcc60009d..b2147be1c1dac 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -20,7 +20,6 @@ import { CreateProgram, createWriteFileMeasuringIO, CustomTransformers, - Debug, Diagnostic, DiagnosticAndArguments, DiagnosticCategory, @@ -109,6 +108,7 @@ import { whitespaceOrMapCommentRegExp, WriteFileCallback, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; const sysFormatDiagnosticsHost: FormatDiagnosticsHost | undefined = sys ? { getCurrentDirectory: () => sys.getCurrentDirectory(), diff --git a/src/compiler/watchPublic.ts b/src/compiler/watchPublic.ts index 24723481e000a..e8eb9e07b25a9 100644 --- a/src/compiler/watchPublic.ts +++ b/src/compiler/watchPublic.ts @@ -24,7 +24,6 @@ import { createWatchCompilerHostOfConfigFile, createWatchCompilerHostOfFilesAndCompilerOptions, createWatchFactory, - Debug, Diagnostic, DiagnosticMessage, DiagnosticReporter, @@ -95,6 +94,7 @@ import { WatchTypeRegistry, WildcardDirectoryWatcher, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; export interface ReadBuildProgramHost { useCaseSensitiveFileNames(): boolean; diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts index 82c9dbf32e28c..a6e9808b1ece8 100644 --- a/src/compiler/watchUtilities.ts +++ b/src/compiler/watchUtilities.ts @@ -7,7 +7,6 @@ import { compareStringsCaseSensitive, CompilerOptions, createGetCanonicalFileName, - Debug, DirectoryWatcherCallback, emptyArray, emptyFileSystemEntries, @@ -59,6 +58,7 @@ import { WatchFileKind, WatchOptions, } from "./_namespaces/ts.js"; +import * as Debug from "./debug.js"; /** * Partial interface of the System thats needed to support the caching of directory structure diff --git a/src/deprecatedCompat/deprecate.ts b/src/deprecatedCompat/deprecate.ts index 634c6e89a58c4..09f01e3af6517 100644 --- a/src/deprecatedCompat/deprecate.ts +++ b/src/deprecatedCompat/deprecate.ts @@ -1,5 +1,5 @@ +import * as Debug from "../compiler/debug.js"; import { - Debug, DeprecationOptions, formatStringFromArgs, noop, diff --git a/src/jsTyping/jsTyping.ts b/src/jsTyping/jsTyping.ts index 4554eb4c731eb..3d55a218d1b57 100644 --- a/src/jsTyping/jsTyping.ts +++ b/src/jsTyping/jsTyping.ts @@ -1,9 +1,9 @@ +import * as Debug from "../compiler/debug.js"; import { CharacterCodes, combinePaths, compareStringsCaseSensitive, CompilerOptions, - Debug, deduplicate, equateStringsCaseSensitive, Extension, diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index c610e072f271b..14a72a3598564 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { addToSeen, arrayFrom, @@ -20,7 +21,6 @@ import { createDocumentRegistryInternal, createGetCanonicalFileName, createMultiMap, - Debug, Diagnostic, directorySeparator, DirectoryStructureHost, diff --git a/src/server/moduleSpecifierCache.ts b/src/server/moduleSpecifierCache.ts index 96d8eb3bf43bc..91912a1129231 100644 --- a/src/server/moduleSpecifierCache.ts +++ b/src/server/moduleSpecifierCache.ts @@ -1,6 +1,6 @@ +import * as Debug from "../compiler/debug.js"; import { closeFileWatcher, - Debug, FileWatcher, ModulePath, ModuleSpecifierCache, diff --git a/src/server/packageJsonCache.ts b/src/server/packageJsonCache.ts index f61c030a15970..6c70981204650 100644 --- a/src/server/packageJsonCache.ts +++ b/src/server/packageJsonCache.ts @@ -1,7 +1,7 @@ +import * as Debug from "../compiler/debug.js"; import { combinePaths, createPackageJsonInfo, - Debug, forEachAncestorDirectoryStoppingAtGlobalCache, getDirectoryPath, Path, diff --git a/src/server/project.ts b/src/server/project.ts index 6df9e1aca3e4a..ccd55a4dca772 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import * as ts from "./_namespaces/ts.js"; import { addRange, @@ -24,7 +25,6 @@ import { createLanguageService, createResolutionCache, createSymlinkCache, - Debug, Diagnostic, directorySeparator, DirectoryStructureHost, diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index afadbe12d50b7..5d0969f985a6e 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { assign, clear, @@ -7,7 +8,6 @@ import { computePositionOfLineAndCharacter, contains, createTextSpanFromBounds, - Debug, directorySeparator, DocumentPositionMapper, DocumentRegistryBucketKeyWithMode, diff --git a/src/server/scriptVersionCache.ts b/src/server/scriptVersionCache.ts index 55a957928a1ae..5c54dceb882db 100644 --- a/src/server/scriptVersionCache.ts +++ b/src/server/scriptVersionCache.ts @@ -1,9 +1,9 @@ +import * as Debug from "../compiler/debug.js"; import { collapseTextChangeRangesAcrossMultipleVersions, computeLineStarts, createTextChangeRange, createTextSpan, - Debug, IScriptSnapshot, TextChangeRange, TextSpan, diff --git a/src/server/session.ts b/src/server/session.ts index c34a18a56011d..a3f13474b24a4 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { arrayFrom, arrayReverseIterator, @@ -22,7 +23,6 @@ import { createSet, createTextSpan, createTextSpanFromBounds, - Debug, decodedTextSpanIntersectsWith, deduplicate, DefinitionInfo, diff --git a/src/server/typingInstallerAdapter.ts b/src/server/typingInstallerAdapter.ts index f92b6bf2a8405..909f22fa3ca47 100644 --- a/src/server/typingInstallerAdapter.ts +++ b/src/server/typingInstallerAdapter.ts @@ -1,8 +1,8 @@ +import * as Debug from "../compiler/debug.js"; import { ApplyCodeActionCommandResult, assertType, createQueue, - Debug, JsTyping, MapLike, server, diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index b3e53fed929b5..f6fc0b0ce3662 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { ArrayLiteralExpression, BinaryExpression, @@ -10,7 +11,6 @@ import { CatchClause, ClassDeclaration, createTextSpanFromBounds, - Debug, DestructuringPattern, DoStatement, EnumDeclaration, diff --git a/src/services/callHierarchy.ts b/src/services/callHierarchy.ts index 77a3b4698e2c0..f74fe95b0a461 100644 --- a/src/services/callHierarchy.ts +++ b/src/services/callHierarchy.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { AccessExpression, append, @@ -18,7 +19,6 @@ import { createTextRangeFromNode, createTextSpanFromBounds, createTextSpanFromRange, - Debug, Decorator, ElementAccessExpression, EmitHint, diff --git a/src/services/classifier.ts b/src/services/classifier.ts index cf2b087aeb85f..c91cd325d7cab 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { __String, arrayToNumericMap, @@ -15,7 +16,6 @@ import { couldStartTrivia, createScanner, createTextSpan, - Debug, decodedTextSpanIntersectsWith, EndOfLineState, EnumDeclaration, diff --git a/src/services/classifier2020.ts b/src/services/classifier2020.ts index 529b0adc03563..890bfdc663f55 100644 --- a/src/services/classifier2020.ts +++ b/src/services/classifier2020.ts @@ -1,10 +1,10 @@ +import * as Debug from "../compiler/debug.js"; import { BindingElement, CancellationToken, Classifications, ClassifiedSpan2020, createTextSpan, - Debug, Declaration, EndOfLineState, forEachChild, diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index 7dbf939b4da05..e0d1d8b35c621 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { arrayFrom, cast, @@ -11,7 +12,6 @@ import { computeSuggestionDiagnostics, contains, createMultiMap, - Debug, Diagnostic, DiagnosticOrDiagnosticAndArguments, diagnosticToString, diff --git a/src/services/codefixes/addMissingInvocationForDecorator.ts b/src/services/codefixes/addMissingInvocationForDecorator.ts index 020768dc8540a..421522a22538a 100644 --- a/src/services/codefixes/addMissingInvocationForDecorator.ts +++ b/src/services/codefixes/addMissingInvocationForDecorator.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js"; import { - Debug, Diagnostics, factory, findAncestor, diff --git a/src/services/codefixes/addMissingResolutionModeImportAttribute.ts b/src/services/codefixes/addMissingResolutionModeImportAttribute.ts index 1467ff9691155..862277ad976ac 100644 --- a/src/services/codefixes/addMissingResolutionModeImportAttribute.ts +++ b/src/services/codefixes/addMissingResolutionModeImportAttribute.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js"; import { - Debug, Diagnostics, factory, findAncestor, diff --git a/src/services/codefixes/addNameToNamelessParameter.ts b/src/services/codefixes/addNameToNamelessParameter.ts index d8e5e24e1cdd6..e146f017292ba 100644 --- a/src/services/codefixes/addNameToNamelessParameter.ts +++ b/src/services/codefixes/addNameToNamelessParameter.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -5,7 +6,6 @@ import { } from "../_namespaces/ts.codefix.js"; import { createRange, - Debug, Diagnostics, factory, findNextToken, diff --git a/src/services/codefixes/annotateWithTypeFromJSDoc.ts b/src/services/codefixes/annotateWithTypeFromJSDoc.ts index 72a9cd7d19297..c7714437c10b0 100644 --- a/src/services/codefixes/annotateWithTypeFromJSDoc.ts +++ b/src/services/codefixes/annotateWithTypeFromJSDoc.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js"; import { - Debug, Diagnostics, EmitFlags, emptyArray, diff --git a/src/services/codefixes/convertToAsyncFunction.ts b/src/services/codefixes/convertToAsyncFunction.ts index 07ac83e40ea19..654e6d03f200d 100644 --- a/src/services/codefixes/convertToAsyncFunction.ts +++ b/src/services/codefixes/convertToAsyncFunction.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -15,7 +16,6 @@ import { CodeFixContext, concatenate, createMultiMap, - Debug, Diagnostics, elementAt, emptyArray, diff --git a/src/services/codefixes/convertToEsModule.ts b/src/services/codefixes/convertToEsModule.ts index 02d1a5f930114..d73344319b74a 100644 --- a/src/services/codefixes/convertToEsModule.ts +++ b/src/services/codefixes/convertToEsModule.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { createCodeFixActionWithoutFixAll, registerCodeFix, @@ -15,7 +16,6 @@ import { copyEntries, createMultiMap, createRange, - Debug, Diagnostics, emptyMap, ExportDeclaration, diff --git a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts index 96a7b8914bfe5..348041709350b 100644 --- a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts +++ b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js"; import { - Debug, Diagnostics, factory, findAncestor, diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 77bec1ed7f173..a75abe9bd1c7f 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { createCodeFixAction, createCodeFixActionWithoutFixAll, @@ -25,7 +26,6 @@ import { CodeFixContextBase, concatenate, createPropertyNameNodeForIdentifierOrLiteral, - Debug, Diagnostics, emptyArray, EnumDeclaration, diff --git a/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts index 3d9bb53799fb0..12e7830252b01 100644 --- a/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts +++ b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js"; import { - Debug, Diagnostics, factory, getTokenAtPosition, diff --git a/src/services/codefixes/fixCannotFindModule.ts b/src/services/codefixes/fixCannotFindModule.ts index d967dea3f188b..9a5266f6aa851 100644 --- a/src/services/codefixes/fixCannotFindModule.ts +++ b/src/services/codefixes/fixCannotFindModule.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js"; import { - Debug, Diagnostics, getTokenAtPosition, getTypesPackageName, diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index a0dd5aa5e5899..a6e913c04496a 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -14,7 +15,6 @@ import { ClassLikeDeclaration, CodeFixAction, createSymbolTable, - Debug, Diagnostics, ExpressionWithTypeArguments, find, diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts index 8f46f23073b9f..db321fae23e14 100644 --- a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -5,7 +6,6 @@ import { } from "../_namespaces/ts.codefix.js"; import { ConstructorDeclaration, - Debug, Diagnostics, emptyArray, factory, diff --git a/src/services/codefixes/fixImplicitThis.ts b/src/services/codefixes/fixImplicitThis.ts index 91be565e56570..eb93d57cd7b39 100644 --- a/src/services/codefixes/fixImplicitThis.ts +++ b/src/services/codefixes/fixImplicitThis.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -5,7 +6,6 @@ import { } from "../_namespaces/ts.codefix.js"; import { ANONYMOUS, - Debug, DiagnosticOrDiagnosticAndArguments, Diagnostics, emptyArray, diff --git a/src/services/codefixes/fixMissingTypeAnnotationOnExports.ts b/src/services/codefixes/fixMissingTypeAnnotationOnExports.ts index bc0a14dbfac51..e0fd87b889400 100644 --- a/src/services/codefixes/fixMissingTypeAnnotationOnExports.ts +++ b/src/services/codefixes/fixMissingTypeAnnotationOnExports.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { createCodeFixAction, createCombinedCodeActions, @@ -20,7 +21,6 @@ import { CodeFixAllContext, CodeFixContext, createPrinter, - Debug, Declaration, defaultMaximumTruncationLength, DiagnosticAndArguments, diff --git a/src/services/codefixes/fixOverrideModifier.ts b/src/services/codefixes/fixOverrideModifier.ts index 360c7eda51c61..28217731bafc9 100644 --- a/src/services/codefixes/fixOverrideModifier.ts +++ b/src/services/codefixes/fixOverrideModifier.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixActionMaybeFixAll, @@ -7,7 +8,6 @@ import { CodeFixAllContext, CodeFixContext, ConstructorDeclaration, - Debug, DiagnosticMessage, Diagnostics, emptyArray, diff --git a/src/services/codefixes/fixPropertyOverrideAccessor.ts b/src/services/codefixes/fixPropertyOverrideAccessor.ts index c1b446bcf7d34..9ca1efd560bec 100644 --- a/src/services/codefixes/fixPropertyOverrideAccessor.ts +++ b/src/services/codefixes/fixPropertyOverrideAccessor.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -8,7 +9,6 @@ import { import { CodeFixAllContext, CodeFixContext, - Debug, Diagnostics, getSourceFileOfNode, getTextOfPropertyName, diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index 21a32bd00c411..a00bd42fb8117 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -5,7 +6,6 @@ import { } from "../_namespaces/ts.codefix.js"; import { CodeFixContextBase, - Debug, Diagnostics, factory, findAncestor, diff --git a/src/services/codefixes/fixStrictClassInitialization.ts b/src/services/codefixes/fixStrictClassInitialization.ts index 4ce6108cea74e..6252ee6b80bea 100644 --- a/src/services/codefixes/fixStrictClassInitialization.ts +++ b/src/services/codefixes/fixStrictClassInitialization.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -8,7 +9,6 @@ import { BigIntLiteralType, CodeFixAction, CodeFixContext, - Debug, Diagnostics, Expression, factory, diff --git a/src/services/codefixes/fixUnreachableCode.ts b/src/services/codefixes/fixUnreachableCode.ts index 948512305f27f..6bbf0a8d4274f 100644 --- a/src/services/codefixes/fixUnreachableCode.ts +++ b/src/services/codefixes/fixUnreachableCode.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js"; import { - Debug, Diagnostics, emptyArray, factory, diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 1974e8067a45f..601fb55ef6696 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -9,7 +10,6 @@ import { cast, CodeFixAction, CodeFixContext, - Debug, DiagnosticMessage, DiagnosticOrDiagnosticAndArguments, Diagnostics, diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 7957b28b110f5..e98b7d75325b2 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { ImportAdder } from "../_namespaces/ts.codefix.js"; import { AccessorDeclaration, @@ -11,7 +12,6 @@ import { ClassLikeDeclaration, CodeFixContextBase, combine, - Debug, Declaration, Diagnostics, emptyArray, diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index d19746cba7826..6c6666b39fd1b 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { createCodeFixAction, createCombinedCodeActions, @@ -26,7 +27,6 @@ import { createModuleSpecifierResolutionHost, createMultiMap, createPackageJsonImportFilter, - Debug, DiagnosticOrDiagnosticAndArguments, Diagnostics, DiagnosticWithLocation, diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index 620542686acab..358f2250a071e 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -16,7 +17,6 @@ import { cast, createMultiMap, createSymbolTable, - Debug, Declaration, DiagnosticMessage, Diagnostics, diff --git a/src/services/codefixes/requireInTs.ts b/src/services/codefixes/requireInTs.ts index 500a88aad8999..8bd4b33bdaf00 100644 --- a/src/services/codefixes/requireInTs.ts +++ b/src/services/codefixes/requireInTs.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -5,7 +6,6 @@ import { } from "../_namespaces/ts.codefix.js"; import { cast, - Debug, Diagnostics, factory, first, diff --git a/src/services/codefixes/returnValueCorrect.ts b/src/services/codefixes/returnValueCorrect.ts index b021eb9f8105c..4c0b2f429cb27 100644 --- a/src/services/codefixes/returnValueCorrect.ts +++ b/src/services/codefixes/returnValueCorrect.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -9,7 +10,6 @@ import { CodeFixContext, copyComments, createSymbolTable, - Debug, Diagnostics, Expression, factory, diff --git a/src/services/codefixes/splitTypeOnlyImport.ts b/src/services/codefixes/splitTypeOnlyImport.ts index 967d6fc837c10..97318123a2c3b 100644 --- a/src/services/codefixes/splitTypeOnlyImport.ts +++ b/src/services/codefixes/splitTypeOnlyImport.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, @@ -5,7 +6,6 @@ import { } from "../_namespaces/ts.codefix.js"; import { CodeFixContextBase, - Debug, Diagnostics, factory, findAncestor, diff --git a/src/services/codefixes/wrapDecoratorInParentheses.ts b/src/services/codefixes/wrapDecoratorInParentheses.ts index 74652e0794509..26222c12cc440 100644 --- a/src/services/codefixes/wrapDecoratorInParentheses.ts +++ b/src/services/codefixes/wrapDecoratorInParentheses.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js"; import { - Debug, Diagnostics, factory, findAncestor, diff --git a/src/services/completions.ts b/src/services/completions.ts index 3291902986fa0..c13395d4ab8d0 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { StringCompletions } from "./_namespaces/ts.Completions.js"; import { __String, @@ -45,7 +46,6 @@ import { createTextSpanFromBounds, createTextSpanFromNode, createTextSpanFromRange, - Debug, Declaration, Decorator, Diagnostics, diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 644f0a125657c..5de97993d7d48 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { __String, arrayFrom, @@ -14,7 +15,6 @@ import { createGetCanonicalFileName, createTextSpanFromBounds, createTextSpanFromNode, - Debug, DefaultClause, find, FindAllReferences, diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index 5c9aefd0a0a05..b31e33f812a0c 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -1,10 +1,10 @@ +import * as Debug from "../compiler/debug.js"; import { arrayFrom, CompilerOptions, createGetCanonicalFileName, createLanguageServiceSourceFile, CreateSourceFileOptions, - Debug, ensureScriptKind, firstDefinedIterator, forEachEntry, diff --git a/src/services/exportInfoMap.ts b/src/services/exportInfoMap.ts index 1bfa8ab018580..41d40325448bc 100644 --- a/src/services/exportInfoMap.ts +++ b/src/services/exportInfoMap.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { __String, addToSeen, @@ -6,7 +7,6 @@ import { CancellationToken, consumesNodeCoreModules, createMultiMap, - Debug, emptyArray, ensureTrailingDirectorySeparator, findIndex, diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 74aeb9c5be05c..bdc044d779938 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { createImportTracker, ExportInfo, @@ -32,7 +33,6 @@ import { createTextSpan, createTextSpanFromBounds, createTextSpanFromRange, - Debug, Declaration, displayPart, DocumentSpan, diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index e641b0f2b0434..a79a4091335d9 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { FormattingContext, FormattingRequestKind, @@ -19,7 +20,6 @@ import { CommentRange, concatenate, createTextChangeFromStartLength, - Debug, Declaration, Diagnostic, EditorSettings, diff --git a/src/services/formatting/formattingContext.ts b/src/services/formatting/formattingContext.ts index ff73e9c578241..5fba71cc5c8b6 100644 --- a/src/services/formatting/formattingContext.ts +++ b/src/services/formatting/formattingContext.ts @@ -1,6 +1,6 @@ +import * as Debug from "../../compiler/debug.js"; import { TextRangeWithKind } from "../_namespaces/ts.formatting.js"; import { - Debug, findChildOfKind, FormatCodeSettings, Node, diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 8a3baa2d13896..99d2f61c8de74 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { createTextRangeWithKind, TextRangeWithKind, @@ -7,7 +8,6 @@ import { import { append, createScanner, - Debug, isJsxAttribute, isJsxElement, isJsxText, diff --git a/src/services/formatting/rulesMap.ts b/src/services/formatting/rulesMap.ts index d3145b2728d64..8cfcab07c2a85 100644 --- a/src/services/formatting/rulesMap.ts +++ b/src/services/formatting/rulesMap.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { anyContext, FormatContext, @@ -8,7 +9,6 @@ import { RuleSpec, } from "../_namespaces/ts.formatting.js"; import { - Debug, every, FormatCodeSettings, FormattingHost, diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index c6ed975a1a516..1bf253b968a04 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { getRangeOfEnclosingComment, TextRangeWithKind, @@ -11,7 +12,6 @@ import { ClassExpression, CommentRange, contains, - Debug, EditorSettings, find, findChildOfKind, diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index cffc15aeeabb3..f73bcba8732f9 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -1,9 +1,9 @@ +import * as Debug from "../compiler/debug.js"; import { combinePaths, createGetCanonicalFileName, createModuleSpecifierResolutionHost, createRange, - Debug, emptyArray, endsWith, ensurePathIsNonModuleName, diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 316d3874fb40e..a8952faf08b26 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { __String, AnyImportOrJsDocImport, @@ -10,7 +11,6 @@ import { canHaveModifiers, canHaveSymbol, cast, - Debug, ExportAssignment, ExportDeclaration, FileReference, diff --git a/src/services/inlayHints.ts b/src/services/inlayHints.ts index a3e54cf237896..a2dc2016f0c09 100644 --- a/src/services/inlayHints.ts +++ b/src/services/inlayHints.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { __String, ArrowFunction, @@ -5,7 +6,6 @@ import { CharacterCodes, createPrinterWithRemoveComments, createTextSpanFromNode, - Debug, ElementFlags, EmitHint, EnumMember, diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 6ca2a1804a8ce..91b36672ec113 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { ArrowFunction, AssignmentDeclarationKind, @@ -18,7 +19,6 @@ import { contains, createTextSpanFromNode, createTextSpanFromRange, - Debug, Declaration, DeclarationName, declarationNameToString, diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 7248133ec8ca7..88a84efaa8586 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { ArrowFunction, Block, @@ -7,7 +8,6 @@ import { createTextSpanFromBounds, createTextSpanFromNode, createTextSpanFromRange, - Debug, DefaultClause, findChildOfKind, getLeadingCommentRanges, diff --git a/src/services/pasteEdits.ts b/src/services/pasteEdits.ts index d3c84b118aa8e..f820c892a25ab 100644 --- a/src/services/pasteEdits.ts +++ b/src/services/pasteEdits.ts @@ -1,7 +1,7 @@ +import * as Debug from "../compiler/debug.js"; import { CancellationToken, codefix, - Debug, fileShouldUseJavaScriptRequire, findAncestor, findIndex, diff --git a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts index 4392c19211061..fdc3f29e94b36 100644 --- a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts +++ b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, ArrowFunction, @@ -5,7 +6,6 @@ import { copyLeadingComments, copyTrailingAsLeadingComments, copyTrailingComments, - Debug, Diagnostics, emptyArray, Expression, diff --git a/src/services/refactors/convertArrowFunctionOrFunctionExpression.ts b/src/services/refactors/convertArrowFunctionOrFunctionExpression.ts index ef0576e59f8bb..15c23ed384fad 100644 --- a/src/services/refactors/convertArrowFunctionOrFunctionExpression.ts +++ b/src/services/refactors/convertArrowFunctionOrFunctionExpression.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, ArrowFunction, @@ -5,7 +6,6 @@ import { ConciseBody, copyComments, copyTrailingAsLeadingComments, - Debug, Diagnostics, emptyArray, factory, diff --git a/src/services/refactors/convertExport.ts b/src/services/refactors/convertExport.ts index 547403bfb07d0..ab37bec33268e 100644 --- a/src/services/refactors/convertExport.ts +++ b/src/services/refactors/convertExport.ts @@ -1,8 +1,8 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, CancellationToken, ClassDeclaration, - Debug, Diagnostics, emptyArray, EnumDeclaration, diff --git a/src/services/refactors/convertImport.ts b/src/services/refactors/convertImport.ts index 1b21d2d5beb02..7ca5472f2ed03 100644 --- a/src/services/refactors/convertImport.ts +++ b/src/services/refactors/convertImport.ts @@ -1,7 +1,7 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, arrayFrom, - Debug, Diagnostics, emptyArray, Expression, diff --git a/src/services/refactors/convertOverloadListToSingleSignature.ts b/src/services/refactors/convertOverloadListToSingleSignature.ts index c9fd31f1b4e70..c457e6b69f610 100644 --- a/src/services/refactors/convertOverloadListToSingleSignature.ts +++ b/src/services/refactors/convertOverloadListToSingleSignature.ts @@ -1,9 +1,9 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, CallSignatureDeclaration, ConstructorDeclaration, ConstructSignatureDeclaration, - Debug, Diagnostics, displayPartsToString, EmitFlags, diff --git a/src/services/refactors/convertParamsToDestructuredObject.ts b/src/services/refactors/convertParamsToDestructuredObject.ts index 9c1792b9b8cbe..60fdb04550e8c 100644 --- a/src/services/refactors/convertParamsToDestructuredObject.ts +++ b/src/services/refactors/convertParamsToDestructuredObject.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { addEmitFlags, ApplicableRefactorInfo, @@ -12,7 +13,6 @@ import { ConstructorDeclaration, contains, copyComments, - Debug, deduplicate, Diagnostics, ElementAccessExpression, diff --git a/src/services/refactors/convertStringOrTemplateLiteral.ts b/src/services/refactors/convertStringOrTemplateLiteral.ts index c6eb8494fe3ad..3dc585bd0b5f6 100644 --- a/src/services/refactors/convertStringOrTemplateLiteral.ts +++ b/src/services/refactors/convertStringOrTemplateLiteral.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, BinaryExpression, BinaryOperator, copyTrailingAsLeadingComments, copyTrailingComments, - Debug, Diagnostics, emptyArray, Expression, diff --git a/src/services/refactors/convertToOptionalChainExpression.ts b/src/services/refactors/convertToOptionalChainExpression.ts index 333e200f6a0b4..658ff6cecaf09 100644 --- a/src/services/refactors/convertToOptionalChainExpression.ts +++ b/src/services/refactors/convertToOptionalChainExpression.ts @@ -1,10 +1,10 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, BinaryExpression, CallExpression, ConditionalExpression, createTextSpanFromBounds, - Debug, Diagnostics, ElementAccessExpression, emptyArray, diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 2d59e42c433d6..d171422241a61 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { __String, ANONYMOUS, @@ -20,7 +21,6 @@ import { ContinueStatement, createDiagnosticForNode, createFileDiagnostic, - Debug, Declaration, Diagnostic, DiagnosticCategory, diff --git a/src/services/refactors/extractType.ts b/src/services/refactors/extractType.ts index b6f4c97b55a5d..1bc5a0ae3e38d 100644 --- a/src/services/refactors/extractType.ts +++ b/src/services/refactors/extractType.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { addRange, addToSeen, @@ -6,7 +7,6 @@ import { cast, concatenate, createTextRangeFromSpan, - Debug, Diagnostics, EmitFlags, emptyArray, diff --git a/src/services/refactors/generateGetAccessorAndSetAccessor.ts b/src/services/refactors/generateGetAccessorAndSetAccessor.ts index 7e0820c3e2224..3ba1a5e1df26c 100644 --- a/src/services/refactors/generateGetAccessorAndSetAccessor.ts +++ b/src/services/refactors/generateGetAccessorAndSetAccessor.ts @@ -1,7 +1,7 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, codefix, - Debug, Diagnostics, emptyArray, getLocaleSpecificMessage, diff --git a/src/services/refactors/helpers.ts b/src/services/refactors/helpers.ts index 38fc8b965f4b9..aa3c87a667102 100644 --- a/src/services/refactors/helpers.ts +++ b/src/services/refactors/helpers.ts @@ -1,7 +1,7 @@ +import * as Debug from "../../compiler/debug.js"; import { ClassLikeDeclaration, codefix, - Debug, findAncestor, FunctionLikeDeclaration, getUniqueName, diff --git a/src/services/refactors/inlineVariable.ts b/src/services/refactors/inlineVariable.ts index d18b94f04472b..670d9e3f3415f 100644 --- a/src/services/refactors/inlineVariable.ts +++ b/src/services/refactors/inlineVariable.ts @@ -1,6 +1,6 @@ +import * as Debug from "../../compiler/debug.js"; import { cast, - Debug, Diagnostics, emptyArray, Expression, diff --git a/src/services/refactors/moveToFile.ts b/src/services/refactors/moveToFile.ts index c1e102fc9c8bf..c9874fde23fa8 100644 --- a/src/services/refactors/moveToFile.ts +++ b/src/services/refactors/moveToFile.ts @@ -1,3 +1,4 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, arrayFrom, @@ -19,7 +20,6 @@ import { createFutureSourceFile, createModuleSpecifierResolutionHost, createTextRangeFromSpan, - Debug, Declaration, DeclarationStatement, Diagnostics, diff --git a/src/services/refactors/moveToNewFile.ts b/src/services/refactors/moveToNewFile.ts index 90971ebaacfd8..cc21c26845e37 100644 --- a/src/services/refactors/moveToNewFile.ts +++ b/src/services/refactors/moveToNewFile.ts @@ -1,8 +1,8 @@ +import * as Debug from "../../compiler/debug.js"; import { ApplicableRefactorInfo, codefix, createFutureSourceFile, - Debug, Diagnostics, emptyArray, findAncestor, diff --git a/src/services/services.ts b/src/services/services.ts index c51089dfe25de..e721099d44096 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { __String, ApplicableRefactorInfo, @@ -46,7 +47,6 @@ import { createTextSpanFromBounds, createTextSpanFromNode, createTextSpanFromRange, - Debug, Declaration, deduplicate, DefinitionInfo, diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 70e9174e64a60..f3ab1c9d35f36 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { ArrowFunction, BinaryExpression, @@ -10,7 +11,6 @@ import { createTextSpan, createTextSpanFromBounds, createTextSpanFromNode, - Debug, ElementFlags, EmitHint, emptyArray, diff --git a/src/services/smartSelection.ts b/src/services/smartSelection.ts index f58862d76ab68..8008166c5f057 100644 --- a/src/services/smartSelection.ts +++ b/src/services/smartSelection.ts @@ -1,9 +1,9 @@ +import * as Debug from "../compiler/debug.js"; import { CharacterCodes, compact, contains, createTextSpanFromBounds, - Debug, findIndex, first, getTokenPosOfNode, diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 7c41dd5e103cf..14cc44b36adef 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { CompletionKind, createCompletionDetails, @@ -33,7 +34,6 @@ import { createSortedArray, createTextSpan, createTextSpanFromStringLiteralLikeContent, - Debug, deduplicate, directorySeparator, ElementAccessExpression, diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 6c49848435e70..9aef6a73deaef 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { addRange, arrayFrom, @@ -6,7 +7,6 @@ import { CheckFlags, contains, createPrinterWithRemoveComments, - Debug, displayPart, EmitHint, emptyArray, diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index e73da8490b683..31b2b0b9951b5 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { addToSeen, ArrowFunction, @@ -20,7 +21,6 @@ import { createTextSpan, createTextSpanFromRange, createTextWriter, - Debug, DeclarationStatement, EmitHint, EmitTextWriter, diff --git a/src/services/transpile.ts b/src/services/transpile.ts index 95722c88a5c05..d0582851d7dad 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { addRange, cloneCompilerOptions, @@ -8,7 +9,6 @@ import { createProgram, createSourceFile, CustomTransformers, - Debug, Diagnostic, fileExtensionIs, filter, diff --git a/src/services/utilities.ts b/src/services/utilities.ts index fe06adeb8b217..568c9a4b45ed7 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1,3 +1,4 @@ +import * as Debug from "../compiler/debug.js"; import { __String, addEmitFlags, @@ -34,7 +35,6 @@ import { createScanner, createTextSpan, createTextSpanFromBounds, - Debug, Declaration, Decorator, DefaultClause, diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index a87008d2766cd..f08af23cebebd 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -1,16 +1,17 @@ +import * as Debug from "../compiler/debug.js"; import * as ts from "./_namespaces/ts.js"; // This file actually uses arguments passed on commandline and executes it // enable deprecation logging -ts.Debug.setLoggingHost({ +Debug.setLoggingHost({ log(_level, s) { ts.sys.write(`${s || ""}${ts.sys.newLine}`); }, }); -if (ts.Debug.isDebugging) { - ts.Debug.enableDebugInfo(); +if (Debug.isDebugging) { + Debug.enableDebugInfo(); } if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) { diff --git a/src/typescript/typescript.ts b/src/typescript/typescript.ts index c3ce1bd27bce4..2c70cfc45285b 100644 --- a/src/typescript/typescript.ts +++ b/src/typescript/typescript.ts @@ -1,4 +1,4 @@ -import { Debug } from "./_namespaces/ts.js"; +import * as Debug from "../compiler/debug.js"; // enable deprecation logging declare const console: any; diff --git a/src/typingsInstallerCore/typingsInstaller.ts b/src/typingsInstallerCore/typingsInstaller.ts index ce9c607b83c02..128d183b1ba46 100644 --- a/src/typingsInstallerCore/typingsInstaller.ts +++ b/src/typingsInstallerCore/typingsInstaller.ts @@ -1,6 +1,6 @@ +import * as Debug from "../compiler/debug.js"; import { combinePaths, - Debug, forEachAncestorDirectory, forEachKey, getBaseFileName,