Skip to content

Commit 2c43171

Browse files
committed
Remove a bunch of namespace uses
1 parent 2784548 commit 2c43171

File tree

13 files changed

+52
-73
lines changed

13 files changed

+52
-73
lines changed

src/compiler/binder.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as ts from "./_namespaces/ts";
21
import { getNodeId } from "./checker";
32
import {
43
append, appendIfUnique, cast, concatenate, contains, every, forEach, getRangesWhere, isString, length, Pattern,
@@ -471,7 +470,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
471470
case SyntaxKind.Parameter:
472471
// Parameters with names are handled at the top of this function. Parameters
473472
// without names can only come from JSDocFunctionTypes.
474-
Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType, "Impossible parameter parent kind", () => `parent is: ${(ts as any).SyntaxKind ? (ts as any).SyntaxKind[node.parent.kind] : node.parent.kind}, expected JSDocFunctionType`);
473+
Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType, "Impossible parameter parent kind", () => `parent is: ${Debug.formatSyntaxKind(node.parent.kind)}, expected JSDocFunctionType`);
475474
const functionType = node.parent as JSDocFunctionType;
476475
const index = functionType.parameters.indexOf(node as ParameterDeclaration);
477476
return "arg" + index as __String;

src/compiler/parser.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as ts from "./_namespaces/ts";
21
import { convertToObjectWorker } from "./commandLineParser";
32
import {
43
addRange, append, AssertionLevel, concatenate, emptyArray, emptyMap, findIndex, forEach, getSpellingSuggestion,
@@ -13,7 +12,7 @@ import {
1312
isAsyncModifier, isExportAssignment, isExportDeclaration, isExportModifier, isExternalModuleReference,
1413
isFunctionTypeNode, isImportDeclaration, isImportEqualsDeclaration, isJSDocFunctionType, isJSDocNullableType,
1514
isJSDocReturnTag, isJSDocTypeTag, isJsxOpeningElement, isJsxOpeningFragment, isMetaProperty, isNonNullExpression,
16-
isPrivateIdentifier, isTaggedTemplateExpression, isTypeReferenceNode,
15+
isPrivateIdentifier, isTaggedTemplateExpression, isTypeReferenceNode, isIdentifier as isIdentifierNode,
1716
} from "./factory/nodeTests";
1817
import { setTextRange } from "./factory/utilitiesPublic";
1918
import { fileExtensionIsOneOf, normalizePath } from "./path";
@@ -1757,7 +1756,7 @@ namespace Parser {
17571756
}
17581757

17591758
// Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message.
1760-
const expressionText = ts.isIdentifier(node) ? idText(node) : undefined;
1759+
const expressionText = isIdentifierNode(node) ? idText(node) : undefined;
17611760
if (!expressionText || !isIdentifierText(expressionText, languageVersion)) {
17621761
parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken));
17631762
return;
@@ -6335,7 +6334,7 @@ namespace Parser {
63356334
let node: ExpressionStatement | LabeledStatement;
63366335
const hasParen = token() === SyntaxKind.OpenParenToken;
63376336
const expression = allowInAnd(parseExpression);
6338-
if (ts.isIdentifier(expression) && parseOptional(SyntaxKind.ColonToken)) {
6337+
if (isIdentifierNode(expression) && parseOptional(SyntaxKind.ColonToken)) {
63396338
node = factory.createLabeledStatement(expression, parseStatement());
63406339
}
63416340
else {
@@ -8393,7 +8392,7 @@ namespace Parser {
83938392
case SyntaxKind.ArrayType:
83948393
return isObjectOrObjectArrayTypeReference((node as ArrayTypeNode).elementType);
83958394
default:
8396-
return isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
8395+
return isTypeReferenceNode(node) && isIdentifierNode(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
83978396
}
83988397
}
83998398

@@ -8664,8 +8663,8 @@ namespace Parser {
86648663
}
86658664

86668665
function escapedTextsEqual(a: EntityName, b: EntityName): boolean {
8667-
while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
8668-
if (!ts.isIdentifier(a) && !ts.isIdentifier(b) && a.right.escapedText === b.right.escapedText) {
8666+
while (!isIdentifierNode(a) || !isIdentifierNode(b)) {
8667+
if (!isIdentifierNode(a) && !isIdentifierNode(b) && a.right.escapedText === b.right.escapedText) {
86698668
a = a.left;
86708669
b = b.left;
86718670
}
@@ -8690,7 +8689,7 @@ namespace Parser {
86908689
const child = tryParseChildTag(target, indent);
86918690
if (child && (child.kind === SyntaxKind.JSDocParameterTag || child.kind === SyntaxKind.JSDocPropertyTag) &&
86928691
target !== PropertyLikeParse.CallbackParameter &&
8693-
name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
8692+
name && (isIdentifierNode(child.name) || !escapedTextsEqual(name, child.name.left))) {
86948693
return false;
86958694
}
86968695
return child;

src/compiler/resolutionCache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as ts from "./_namespaces/ts";
21
import {
32
arrayToMap, contains, createMultiMap, emptyIterator, endsWith, firstDefinedIterator, GetCanonicalFileName, isString,
43
length, memoize, removeSuffix, returnTrue, some, startsWith, stringContains, unorderedRemoveItem,
@@ -10,6 +9,7 @@ import {
109
CacheWithRedirects, createCacheWithRedirects, createModeAwareCache, createModuleResolutionCache,
1110
createTypeReferenceDirectiveResolutionCache, getEffectiveTypeRoots, isTraceEnabled, loadModuleFromGlobalCache,
1211
ModeAwareCache, ModuleResolutionCache, parseNodeModuleFromPath, pathContainsNodeModules, PerModuleNameCache, trace,
12+
resolveTypeReferenceDirective as internalResolveTypeReferenceDirective, resolveModuleName as internalResolveModuleName,
1313
} from "./moduleNameResolver";
1414
import {
1515
directorySeparator, fileExtensionIs, fileExtensionIsOneOf, getDirectoryPath, getNormalizedAbsolutePath,
@@ -349,7 +349,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
349349
}
350350

351351
function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, _containingSourceFile?: never, mode?: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): CachedResolvedModuleWithFailedLookupLocations {
352-
const primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
352+
const primaryResult = internalResolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
353353
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
354354
if (!resolutionHost.getGlobalCache) {
355355
return primaryResult;
@@ -381,7 +381,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
381381
}
382382

383383
function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, _containingSourceFile?: SourceFile, resolutionMode?: SourceFile["impliedNodeFormat"] | undefined): CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations {
384-
return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
384+
return internalResolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
385385
}
386386

387387
interface ResolveNamesWithLocalCacheInput<T extends ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName> {

src/compiler/transformers/declarations/diagnostics.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as ts from "../../_namespaces/ts";
21
import { Debug } from "../../debug";
32
import { Diagnostics } from "../../diagnosticInformationMap.generated";
43
import {
@@ -185,7 +184,7 @@ export function createGetSymbolAccessibilityDiagnosticForNode(node: DeclarationD
185184
return getTypeAliasDeclarationVisibilityError;
186185
}
187186
else {
188-
return Debug.assertNever(node, `Attempted to set a declaration diagnostic context for unhandled node kind: ${(ts as any).SyntaxKind[(node as any).kind]}`);
187+
return Debug.assertNever(node, `Attempted to set a declaration diagnostic context for unhandled node kind: ${Debug.formatSyntaxKind((node as any).kind)}`);
189188
}
190189

191190
function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) {
@@ -414,7 +413,7 @@ export function createGetSymbolAccessibilityDiagnosticForNode(node: DeclarationD
414413
Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
415414

416415
default:
417-
return Debug.fail(`Unknown parent for parameter: ${(ts as any).SyntaxKind[node.parent.kind]}`);
416+
return Debug.fail(`Unknown parent for parameter: ${Debug.formatSyntaxKind(node.parent.kind)}`);
418417
}
419418
}
420419

src/compiler/tsbuildPublic.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as ts from "./_namespaces/ts";
21
import {
32
AffectedFileResult, BuilderProgram, EmitAndSemanticDiagnosticsBuilderProgram, SemanticDiagnosticsBuilderProgram,
43
} from "./builderPublic";
@@ -23,7 +22,7 @@ import {
2322
resolveTypeReferenceDirective, TypeReferenceDirectiveResolutionCache,
2423
} from "./moduleNameResolver";
2524
import { isDeclarationFileName } from "./parser";
26-
import { convertToRelativePath, getDirectoryPath, resolvePath } from "./path";
25+
import { convertToRelativePath, getDirectoryPath, resolvePath, toPath as internalToPath } from "./path";
2726
import {
2827
changeCompilerHostLikeToUseCache, flattenDiagnosticMessageText, ForegroundColorEscapeSequences, formatColorAndReset,
2928
getConfigFileParsingDiagnostics, loadWithModeAwareCache, loadWithTypeDirectiveCache,
@@ -408,7 +407,7 @@ function createSolutionBuilderState<T extends BuilderProgram>(watch: boolean, ho
408407
}
409408

410409
function toPath(state: SolutionBuilderState, fileName: string) {
411-
return ts.toPath(fileName, state.currentDirectory, state.getCanonicalFileName);
410+
return internalToPath(fileName, state.currentDirectory, state.getCanonicalFileName);
412411
}
413412

414413
function toResolvedConfigFilePath(state: SolutionBuilderState, fileName: ResolvedConfigFileName): ResolvedConfigFilePath {

src/compiler/watch.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as ts from "./_namespaces/ts";
21
import {
32
BuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram, EmitAndSemanticDiagnosticsBuilderProgram,
43
} from "./builderPublic";
@@ -42,7 +41,7 @@ import {
4241
createIncrementalCompilerHost, createIncrementalProgram, CreateProgram, ProgramHost, WatchCompilerHost,
4342
WatchCompilerHostOfConfigFile, WatchCompilerHostOfFilesAndCompilerOptions, WatchHost, WatchStatusReporter,
4443
} from "./watchPublic";
45-
import { DirectoryStructureHost, getWatchFactory, WatchFactoryHost, WatchLogLevel } from "./watchUtilities";
44+
import { DirectoryStructureHost, getWatchFactory, WatchFactoryHost, WatchLogLevel, WatchFactory as InternalWatchFactory } from "./watchUtilities";
4645

4746
const sysFormatDiagnosticsHost: FormatDiagnosticsHost | undefined = sys ? {
4847
getCurrentDirectory: () => sys.getCurrentDirectory(),
@@ -613,7 +612,7 @@ export interface WatchTypeRegistry {
613612
NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation",
614613
}
615614

616-
interface WatchFactory<X, Y = undefined> extends ts.WatchFactory<X, Y> {
615+
interface WatchFactory<X, Y = undefined> extends InternalWatchFactory<X, Y> {
617616
writeLog: (s: string) => void;
618617
}
619618

src/debug/dbg.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as Debug from "./_namespaces/Debug";
2-
31
/// <reference lib="es2019" />
42

53
interface Node {
@@ -510,9 +508,3 @@ export function formatControlFlowGraph(flowNode: FlowNode) {
510508
return s;
511509
}
512510
}
513-
514-
// Export as a module. NOTE: Can't use module exports as this is built using --outFile
515-
declare const module: { exports: {} };
516-
if (typeof module !== "undefined" && module.exports) {
517-
module.exports = Debug;
518-
}

0 commit comments

Comments
 (0)