Skip to content

Commit c30f78c

Browse files
committed
use direct imports
1 parent b553aff commit c30f78c

File tree

230 files changed

+6949
-5222
lines changed

Some content is hidden

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

230 files changed

+6949
-5222
lines changed

src/compiler/binder.ts

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,74 @@
1+
import * as performance from "./performance";
2+
import { getNodeId } from "./checkerUtilities";
13
import {
2-
__String, AccessExpression, addRelatedInfo, append, appendIfUnique, ArrayBindingElement, ArrayLiteralExpression,
3-
ArrowFunction, AssignmentDeclarationKind, BinaryExpression, BinaryOperatorToken, BindableAccessExpression,
4-
BindableObjectDefinePropertyCall, BindablePropertyAssignmentExpression, BindableStaticAccessExpression,
5-
BindableStaticNameExpression, BindableStaticPropertyAssignmentExpression, BindingElement, Block,
6-
BreakOrContinueStatement, CallChain, CallExpression, CaseBlock, CaseClause, cast, CatchClause, ClassLikeDeclaration,
7-
ClassStaticBlockDeclaration, CompilerOptions, concatenate, ConditionalExpression, ConditionalTypeNode, contains,
8-
createBinaryExpressionTrampoline, createDiagnosticForNodeInSourceFile, createFileDiagnostic, createQueue,
9-
createSymbolTable, Debug, Declaration, declarationNameToString, DeleteExpression, DestructuringAssignment,
10-
DiagnosticCategory, DiagnosticMessage, DiagnosticRelatedInformation, Diagnostics, DiagnosticWithLocation,
11-
DoStatement, DynamicNamedDeclaration, ElementAccessChain, ElementAccessExpression, EntityNameExpression,
12-
EnumDeclaration, escapeLeadingUnderscores, every, ExportAssignment, exportAssignmentIsAlias,
13-
ExportDeclaration, ExportSpecifier, Expression, ExpressionStatement, findAncestor, FlowFlags, FlowLabel, FlowNode,
14-
FlowReduceLabel, forEach, forEachChild, ForInOrOfStatement, ForStatement, FunctionDeclaration, FunctionExpression,
15-
FunctionLikeDeclaration, GetAccessorDeclaration, getAssignedExpandoInitializer, getAssignmentDeclarationKind,
16-
getAssignmentDeclarationPropertyAccessKind, getCombinedModifierFlags, getCombinedNodeFlags, getContainingClass,
17-
getEffectiveContainerForJSDocTemplateTag, getElementOrPropertyAccessName, getEmitScriptTarget,
4+
append, appendIfUnique, cast, concatenate, contains, createQueue, every, forEach, getRangesWhere,
5+
isString, length, Pattern, some, tryCast,
6+
} from "./core";
7+
import { Debug } from "./debug";
8+
import { Diagnostics } from "./diagnosticInformationMap.generated";
9+
import { createBinaryExpressionTrampoline } from "./factory/binaryExpressionStateMachine";
10+
import {
11+
isBinaryExpression, isBlock, isCallExpression, isClassStaticBlockDeclaration, isConditionalTypeNode,
12+
isElementAccessExpression, isEnumDeclaration, isExportAssignment, isExportDeclaration, isExportSpecifier, isFunctionDeclaration,
13+
isIdentifier, isJSDocEnumTag, isJSDocTemplateTag, isModuleBlock, isModuleDeclaration, isNamespaceExport, isNonNullExpression,
14+
isObjectLiteralExpression, isOmittedExpression, isParenthesizedExpression, isPrefixUnaryExpression, isPrivateIdentifier,
15+
isPropertyAccessExpression, isShorthandPropertyAssignment, isSourceFile, isTypeAliasDeclaration, isTypeOfExpression,
16+
isVariableDeclaration, isVariableStatement,
17+
} from "./factory/nodeTests";
18+
import { forEachChild, isExternalModule } from "./parser";
19+
import { perfLogger } from "./perfLogger";
20+
import { tokenToString } from "./scanner";
21+
import { tracing, TracingNode } from "./tracing";
22+
import {
23+
__String, AccessExpression, ArrayBindingElement, ArrayLiteralExpression, ArrowFunction, AssignmentDeclarationKind,
24+
BinaryExpression, BinaryOperatorToken, BindableAccessExpression, BindableObjectDefinePropertyCall,
25+
BindablePropertyAssignmentExpression, BindableStaticAccessExpression, BindableStaticNameExpression,
26+
BindableStaticPropertyAssignmentExpression, BindingElement, Block, BreakOrContinueStatement, CallChain, CallExpression,
27+
CaseBlock, CaseClause, CatchClause, ClassLikeDeclaration, ClassStaticBlockDeclaration, CompilerOptions, ConditionalExpression,
28+
ConditionalTypeNode, Declaration, DeleteExpression, DestructuringAssignment, DiagnosticCategory, DiagnosticMessage,
29+
DiagnosticRelatedInformation, DiagnosticWithLocation, DoStatement, DynamicNamedDeclaration, ElementAccessChain,
30+
ElementAccessExpression, EntityNameExpression, EnumDeclaration, ExportAssignment, ExportDeclaration, ExportSpecifier,
31+
Expression, ExpressionStatement, FlowFlags, FlowLabel, FlowNode, FlowReduceLabel, ForInOrOfStatement, ForStatement,
32+
FunctionDeclaration, FunctionExpression, FunctionLikeDeclaration, GetAccessorDeclaration, Identifier, IfStatement, ImportClause,
33+
InternalSymbolName, JSDocCallbackTag, JSDocClassTag, JSDocEnumTag, JSDocFunctionType, JSDocParameterTag, JSDocPropertyLikeTag,
34+
JSDocSignature, JSDocTypedefTag, JSDocTypeLiteral, JsxAttribute, JsxAttributes, LabeledStatement, LiteralLikeElementAccessExpression,
35+
MappedTypeNode, MethodDeclaration, ModifierFlags, ModuleBlock, ModuleDeclaration, NamespaceExportDeclaration, Node, NodeArray, NodeFlags,
36+
NonNullChain, NonNullExpression, NumericLiteral, ObjectLiteralExpression, OptionalChain, ParameterDeclaration, ParenthesizedExpression,
37+
PatternAmbientModule, PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessChain, PropertyAccessExpression,
38+
PropertyDeclaration, PropertySignature, ReturnStatement, ScriptTarget, SetAccessorDeclaration, ShorthandPropertyAssignment,
39+
SignatureDeclaration, SourceFile, SpreadElement, Statement, StringLiteral, SwitchStatement, Symbol, SymbolFlags, SymbolTable,
40+
SyntaxKind, TextRange, ThrowStatement, TokenFlags, TryStatement, TypeLiteralNode, TypeOfExpression, TypeParameterDeclaration,
41+
VariableDeclaration, WhileStatement, WithStatement,
42+
} from "./types";
43+
import {
44+
addRelatedInfo, createDiagnosticForNodeInSourceFile, createFileDiagnostic, createSymbolTable, declarationNameToString,
45+
exportAssignmentIsAlias, getAssignedExpandoInitializer, getAssignmentDeclarationKind, getAssignmentDeclarationPropertyAccessKind,
46+
getContainingClass, getEffectiveContainerForJSDocTemplateTag, getElementOrPropertyAccessName, getEmitScriptTarget,
1847
getEnclosingBlockScopeContainer, getErrorSpanForNode, getEscapedTextOfIdentifierOrLiteral, getExpandoInitializer,
19-
getHostSignatureFromJSDoc, getImmediatelyInvokedFunctionExpression, getJSDocTypeTag, getLeftmostAccessExpression,
20-
getNameOfDeclaration, getNameOrArgument, getNodeId, getRangesWhere, getRightMostAssignedExpression,
21-
getSourceFileOfNode, getSourceTextOfNodeFromSourceFile, getSpanOfTokenAtPosition, getStrictOptionValue,
22-
getSymbolNameForPrivateIdentifier, getTextOfIdentifierOrLiteral, getThisContainer, getTokenPosOfNode,
23-
hasDynamicName, hasJSDocNodes, hasSyntacticModifier, Identifier, idText, IfStatement, ImportClause,
24-
InternalSymbolName, isAliasableExpression, isAmbientModule, isAssignmentExpression, isAssignmentOperator,
25-
isAssignmentTarget, isAsyncFunction, isAutoAccessorPropertyDeclaration, isBinaryExpression,
26-
isBindableObjectDefinePropertyCall, isBindableStaticAccessExpression, isBindableStaticNameExpression,
27-
isBindingPattern, isBlock, isBlockOrCatchScoped, isCallExpression, isClassStaticBlockDeclaration,
28-
isConditionalTypeNode, isDeclaration, isDeclarationStatement, isDestructuringAssignment, isDottedName,
29-
isElementAccessExpression, isEmptyObjectLiteral, isEntityNameExpression, isEnumConst, isEnumDeclaration,
30-
isExportAssignment, isExportDeclaration, isExportsIdentifier, isExportSpecifier, isExpression,
31-
isExpressionOfOptionalChainRoot, isExternalModule, isExternalOrCommonJsModule, isForInOrOfStatement,
32-
isFunctionDeclaration, isFunctionLike, isFunctionLikeDeclaration, isFunctionLikeOrClassStaticBlockDeclaration,
33-
isFunctionSymbol, isGlobalScopeAugmentation, isIdentifier, isIdentifierName, isInJSFile, isInTopLevelContext,
34-
isJSDocConstructSignature, isJSDocEnumTag, isJSDocTemplateTag, isJSDocTypeAlias, isJsonSourceFile,
35-
isLeftHandSideExpression, isLogicalOrCoalescingAssignmentOperator, isModuleAugmentationExternal, isModuleBlock,
36-
isModuleDeclaration, isModuleExportsAccessExpression, isNamedDeclaration, isNamespaceExport, isNonNullExpression,
37-
isNullishCoalesce, isObjectLiteralExpression, isObjectLiteralMethod,
38-
isObjectLiteralOrClassExpressionMethodOrAccessor, isOmittedExpression, isOptionalChain, isOptionalChainRoot,
39-
isOutermostOptionalChain, isParameterDeclaration, isParameterPropertyDeclaration, isParenthesizedExpression,
40-
isPartOfTypeQuery, isPrefixUnaryExpression, isPrivateIdentifier, isPrologueDirective,
41-
isPropertyAccessEntityNameExpression, isPropertyAccessExpression, isPropertyNameLiteral, isPrototypeAccess,
42-
isPushOrUnshiftIdentifier, isRequireCall, isShorthandPropertyAssignment, isSignedNumericLiteral, isSourceFile,
43-
isSpecialPropertyDeclaration, isStatement, isStatementButNotDeclaration, isStatic, isString, isStringLiteralLike,
44-
isStringOrNumericLiteralLike, isThisInitializedDeclaration, isTypeAliasDeclaration, isTypeOfExpression,
45-
isVariableDeclaration, isVariableDeclarationInitializedToBareOrAccessedRequire, isVariableStatement,
46-
JSDocCallbackTag, JSDocClassTag, JSDocEnumTag, JSDocFunctionType, JSDocParameterTag, JSDocPropertyLikeTag,
47-
JSDocSignature, JSDocTypedefTag, JSDocTypeLiteral, JsxAttribute, JsxAttributes, LabeledStatement, length,
48-
LiteralLikeElementAccessExpression, MappedTypeNode, MethodDeclaration, ModifierFlags, ModuleBlock,
49-
ModuleDeclaration, Mutable, NamespaceExportDeclaration, Node, NodeArray, NodeFlags, nodeHasName, nodeIsMissing,
50-
nodeIsPresent, NonNullChain, NonNullExpression, NumericLiteral, objectAllocator, ObjectLiteralExpression,
51-
OptionalChain, ParameterDeclaration, ParenthesizedExpression, Pattern, PatternAmbientModule, perfLogger,
52-
PostfixUnaryExpression, PrefixUnaryExpression, PrivateIdentifier, PropertyAccessChain, PropertyAccessExpression,
53-
PropertyDeclaration, PropertySignature, removeFileExtension, ReturnStatement, ScriptTarget,
54-
SetAccessorDeclaration, setParent, setParentRecursive, setValueDeclaration, ShorthandPropertyAssignment,
55-
shouldPreserveConstEnums, SignatureDeclaration, skipParentheses, sliceAfter, some, SourceFile, SpreadElement,
56-
Statement, StringLiteral, SwitchStatement, Symbol, SymbolFlags, symbolName, SymbolTable, SyntaxKind, TextRange,
57-
ThrowStatement, TokenFlags, tokenToString, tracing, TracingNode, tryCast, tryParsePattern, TryStatement,
58-
TypeLiteralNode, TypeOfExpression, TypeParameterDeclaration, unescapeLeadingUnderscores, unreachableCodeIsError,
59-
unusedLabelIsError, VariableDeclaration, WhileStatement, WithStatement,
60-
} from "./_namespaces/ts";
61-
import * as performance from "./_namespaces/ts.performance";
48+
getHostSignatureFromJSDoc, getImmediatelyInvokedFunctionExpression, getLeftmostAccessExpression, getNameOrArgument,
49+
getRightMostAssignedExpression, getSourceFileOfNode, getSourceTextOfNodeFromSourceFile, getSpanOfTokenAtPosition,
50+
getStrictOptionValue, getSymbolNameForPrivateIdentifier, getTextOfIdentifierOrLiteral, getThisContainer, getTokenPosOfNode,
51+
hasDynamicName, hasSyntacticModifier, isAliasableExpression, isAmbientModule, isAssignmentExpression, isAssignmentOperator,
52+
isAssignmentTarget, isAsyncFunction, isBindableObjectDefinePropertyCall, isBindableStaticAccessExpression,
53+
isBindableStaticNameExpression, isBlockOrCatchScoped, isDestructuringAssignment, isDottedName, isEmptyObjectLiteral,
54+
isEntityNameExpression, isEnumConst, isExportsIdentifier, isExternalOrCommonJsModule, isFunctionSymbol, isGlobalScopeAugmentation,
55+
isIdentifierName, isInJSFile, isInTopLevelContext, isJSDocConstructSignature, isJSDocTypeAlias, isJsonSourceFile,
56+
isLogicalOrCoalescingAssignmentOperator, isModuleAugmentationExternal, isModuleExportsAccessExpression,
57+
isObjectLiteralMethod, isObjectLiteralOrClassExpressionMethodOrAccessor, isParameterDeclaration, isPartOfTypeQuery,
58+
isPrologueDirective, isPropertyAccessEntityNameExpression, isPropertyNameLiteral, isPrototypeAccess, isPushOrUnshiftIdentifier,
59+
isRequireCall, isSignedNumericLiteral, isSpecialPropertyDeclaration, isStatic, isStringOrNumericLiteralLike, isThisInitializedDeclaration,
60+
isVariableDeclarationInitializedToBareOrAccessedRequire, Mutable, nodeIsMissing, nodeIsPresent, objectAllocator, removeFileExtension,
61+
setParent, setParentRecursive, setValueDeclaration, shouldPreserveConstEnums, skipParentheses, sliceAfter, tryParsePattern,
62+
unreachableCodeIsError, unusedLabelIsError,
63+
} from "./utilities";
64+
import {
65+
escapeLeadingUnderscores, findAncestor, getCombinedModifierFlags, getCombinedNodeFlags, getJSDocTypeTag, getNameOfDeclaration,
66+
hasJSDocNodes, idText, isAutoAccessorPropertyDeclaration, isBindingPattern, isDeclaration, isDeclarationStatement, isExpression,
67+
isExpressionOfOptionalChainRoot, isForInOrOfStatement, isFunctionLike, isFunctionLikeDeclaration,
68+
isFunctionLikeOrClassStaticBlockDeclaration, isLeftHandSideExpression, isNamedDeclaration, isNullishCoalesce, isOptionalChain,
69+
isOptionalChainRoot, isOutermostOptionalChain, isParameterPropertyDeclaration, isStatement, isStatementButNotDeclaration,
70+
isStringLiteralLike, nodeHasName, symbolName, unescapeLeadingUnderscores,
71+
} from "./utilitiesPublic";
6272

6373
/** @internal */
6474
export const enum ModuleInstanceState {

src/compiler/builder.ts

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
import * as ts from "./_namespaces/ts";
21
import {
3-
addRange, AffectedFileResult, arrayFrom, arrayToMap, BuilderProgram, BuilderProgramHost, BuilderState, BuildInfo,
4-
BundleBuildInfo, CancellationToken, CommandLineOption, compareStringsCaseSensitive, compareValues, CompilerHost,
5-
CompilerOptions, compilerOptionsAffectDeclarationPath, compilerOptionsAffectEmit,
6-
compilerOptionsAffectSemanticDiagnostics, CompilerOptionsValue, concatenate, convertToOptionsWithAbsolutePaths,
7-
createBuildInfo, createGetCanonicalFileName, createProgram, CustomTransformers, Debug, Diagnostic,
8-
DiagnosticCategory, DiagnosticMessageChain, DiagnosticRelatedInformation, DiagnosticWithLocation,
9-
EmitAndSemanticDiagnosticsBuilderProgram, EmitOnly, EmitResult, emitSkippedWithNoDiagnostics, emptyArray,
10-
ensurePathIsNonModuleName, filterSemanticDiagnostics, forEach, forEachEntry, forEachKey, generateDjb2Hash,
11-
GetCanonicalFileName, getDirectoryPath, getEmitDeclarations, getNormalizedAbsolutePath, getOptionsNameMap,
12-
getOwnKeys, getRelativePathFromDirectory, getTsBuildInfoEmitOutputFilePath, handleNoEmitOptions, isArray,
13-
isDeclarationFileName, isJsonSourceFile, isNumber, isString, map, mapDefined, maybeBind, noop, notImplemented,
14-
outFile, Path, Program, ProjectReference, ReadBuildProgramHost, ReadonlyCollection,
15-
returnFalse, returnUndefined, SemanticDiagnosticsBuilderProgram, skipTypeChecking, some, SourceFile,
16-
sourceFileMayBeEmitted, SourceMapEmitResult, toPath, tryAddToSet, WriteFileCallback, WriteFileCallbackData,
17-
} from "./_namespaces/ts";
2+
AffectedFileResult, BuilderProgram, BuilderProgramHost,
3+
EmitAndSemanticDiagnosticsBuilderProgram, SemanticDiagnosticsBuilderProgram,
4+
} from "./builderPublic";
5+
import { BuilderState } from "./builderState";
6+
import { convertToOptionsWithAbsolutePaths, getOptionsNameMap } from "./commandLineParser";
7+
import {
8+
addRange, arrayFrom, arrayToMap, compareStringsCaseSensitive, compareValues, concatenate, createGetCanonicalFileName,
9+
emptyArray, forEach, GetCanonicalFileName, getOwnKeys, isArray, isNumber, isString, map, mapDefined, maybeBind, noop,
10+
notImplemented, returnFalse, returnUndefined, some, tryAddToSet,
11+
} from "./core";
12+
import { ReadonlyCollection } from "./corePublic";
13+
import { Debug } from "./debug";
14+
import { createBuildInfo, getTsBuildInfoEmitOutputFilePath } from "./emitter";
15+
import { isDeclarationFileName } from "./parser";
16+
import {
17+
ensurePathIsNonModuleName, getDirectoryPath, getNormalizedAbsolutePath,
18+
getRelativePathFromDirectory, toPath,
19+
} from "./path";
20+
import { createProgram, emitSkippedWithNoDiagnostics, filterSemanticDiagnostics, handleNoEmitOptions } from "./program";
21+
import { generateDjb2Hash } from "./sys";
22+
import {
23+
BuildInfo, BundleBuildInfo, CancellationToken, CommandLineOption, CompilerHost, CompilerOptions, CompilerOptionsValue,
24+
CustomTransformers, Diagnostic, DiagnosticCategory, DiagnosticMessageChain, DiagnosticRelatedInformation, DiagnosticWithLocation,
25+
EmitOnly, EmitResult, Path, Program, ProjectReference, SourceFile, SourceMapEmitResult, WriteFileCallback, WriteFileCallbackData,
26+
} from "./types";
27+
import {
28+
compilerOptionsAffectDeclarationPath, compilerOptionsAffectEmit, compilerOptionsAffectSemanticDiagnostics, forEachEntry,
29+
forEachKey, getEmitDeclarations, isJsonSourceFile, outFile, skipTypeChecking, sourceFileMayBeEmitted,
30+
} from "./utilities";
31+
import { ReadBuildProgramHost } from "./watchPublic";
1832

1933
/** @internal */
2034
export interface ReusableDiagnostic extends ReusableDiagnosticRelatedInformation {
@@ -385,22 +399,22 @@ function convertToDiagnostics(diagnostics: readonly ReusableDiagnostic[], newPro
385399
if (!diagnostics.length) return emptyArray;
386400
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions())!, newProgram.getCurrentDirectory()));
387401
return diagnostics.map(diagnostic => {
388-
const result: Diagnostic = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
402+
const result: Diagnostic = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPathHelper);
389403
result.reportsUnnecessary = diagnostic.reportsUnnecessary;
390404
result.reportsDeprecated = diagnostic.reportDeprecated;
391405
result.source = diagnostic.source;
392406
result.skippedOn = diagnostic.skippedOn;
393407
const { relatedInformation } = diagnostic;
394408
result.relatedInformation = relatedInformation ?
395409
relatedInformation.length ?
396-
relatedInformation.map(r => convertToDiagnosticRelatedInformation(r, newProgram, toPath)) :
410+
relatedInformation.map(r => convertToDiagnosticRelatedInformation(r, newProgram, toPathHelper)) :
397411
[] :
398412
undefined;
399413
return result;
400414
});
401415

402-
function toPath(path: string) {
403-
return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
416+
function toPathHelper(path: string) {
417+
return toPath(path, buildInfoDirectory, getCanonicalFileName);
404418
}
405419
}
406420

@@ -1625,7 +1639,7 @@ export function createBuilderProgramUsingProgramBuildInfo(buildInfo: BuildInfo,
16251639
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
16261640

16271641
let state: ReusableBuilderProgramState;
1628-
const filePaths = program.fileNames?.map(toPath);
1642+
const filePaths = program.fileNames?.map(toPathHelper);
16291643
let filePathsSetList: Set<Path>[] | undefined;
16301644
const latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
16311645
if (isProgramBundleEmitBuildInfo(program)) {
@@ -1705,8 +1719,8 @@ export function createBuilderProgramUsingProgramBuildInfo(buildInfo: BuildInfo,
17051719
hasChangedEmitSignature: returnFalse,
17061720
};
17071721

1708-
function toPath(path: string) {
1709-
return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
1722+
function toPathHelper(path: string) {
1723+
return toPath(path, buildInfoDirectory, getCanonicalFileName);
17101724
}
17111725

17121726
function toAbsolutePath(path: string) {

0 commit comments

Comments
 (0)