Skip to content

Commit 3188a82

Browse files
Remove binder from transpileDeclaration implementation.
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
1 parent 418f975 commit 3188a82

File tree

9 files changed

+277
-1038
lines changed

9 files changed

+277
-1038
lines changed

src/compiler/_namespaces/ts.ts

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export * from "../transformers/module/system";
5757
export * from "../transformers/module/esnextAnd2015";
5858
export * from "../transformers/module/node";
5959
export * from "../transformers/declarations/diagnostics";
60-
export * from "../transformers/declarations/emitBinder";
6160
export * from "../transformers/declarations/emitResolver";
6261
export * from "../transformers/declarations/transpileDeclaration";
6362
export * from "../transformers/declarations/localInferenceResolver";

src/compiler/checker.ts

+3-61
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ import {
241241
getAllJSDocTags,
242242
getAllowSyntheticDefaultImports,
243243
getAncestor,
244-
getAnyImportSyntax,
245244
getAssignedExpandoInitializer,
246245
getAssignmentDeclarationKind,
247246
getAssignmentDeclarationPropertyAccessKind,
@@ -329,6 +328,7 @@ import {
329328
getModeForUsageLocation,
330329
getModifiers,
331330
getModuleInstanceState,
331+
getModuleSpecifierForImportOrExport,
332332
getNameFromImportAttribute,
333333
getNameFromIndexInfo,
334334
getNameOfDeclaration,
@@ -1477,14 +1477,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
14771477
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;
14781478
var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
14791479

1480-
var { hasVisibleDeclarations, isEntityNameVisible } = createEntityVisibilityChecker({
1480+
var { hasVisibleDeclarations, isEntityNameVisible, collectLinkedAliases } = createEntityVisibilityChecker({
14811481
defaultSymbolAccessibility: SymbolAccessibility.NotAccessible,
14821482
isThisAccessible,
14831483
isDeclarationVisible,
14841484
markDeclarationAsVisible(declaration) {
14851485
getNodeLinks(declaration).isVisible = true;
14861486
},
14871487
resolveName,
1488+
getTargetOfExportSpecifier,
14881489
});
14891490
var checkBinaryExpression = createCheckBinaryExpression();
14901491
var emitResolver = createResolver();
@@ -4168,23 +4169,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
41684169
return exportDefaultSymbol;
41694170
}
41704171

4171-
function getModuleSpecifierForImportOrExport(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportOrExportSpecifier): Expression | undefined {
4172-
switch (node.kind) {
4173-
case SyntaxKind.ImportClause:
4174-
return node.parent.moduleSpecifier;
4175-
case SyntaxKind.ImportEqualsDeclaration:
4176-
return isExternalModuleReference(node.moduleReference) ? node.moduleReference.expression : undefined;
4177-
case SyntaxKind.NamespaceImport:
4178-
return node.parent.parent.moduleSpecifier;
4179-
case SyntaxKind.ImportSpecifier:
4180-
return node.parent.parent.parent.moduleSpecifier;
4181-
case SyntaxKind.ExportSpecifier:
4182-
return node.parent.parent.moduleSpecifier;
4183-
default:
4184-
return Debug.assertNever(node);
4185-
}
4186-
}
4187-
41884172
function reportNonDefaultExport(moduleSymbol: Symbol, node: ImportClause) {
41894173
if (moduleSymbol.exports?.has(node.symbol.escapedName)) {
41904174
error(
@@ -10367,48 +10351,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1036710351
return false;
1036810352
}
1036910353

10370-
function collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined {
10371-
let exportSymbol: Symbol | undefined;
10372-
if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) {
10373-
exportSymbol = resolveName(node, node.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false);
10374-
}
10375-
else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
10376-
exportSymbol = getTargetOfExportSpecifier(node.parent as ExportSpecifier, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
10377-
}
10378-
let result: Node[] | undefined;
10379-
let visited: Set<number> | undefined;
10380-
if (exportSymbol) {
10381-
visited = new Set();
10382-
visited.add(getSymbolId(exportSymbol));
10383-
buildVisibleNodeList(exportSymbol.declarations);
10384-
}
10385-
return result;
10386-
10387-
function buildVisibleNodeList(declarations: Declaration[] | undefined) {
10388-
forEach(declarations, declaration => {
10389-
const resultNode = getAnyImportSyntax(declaration) || declaration;
10390-
if (setVisibility) {
10391-
getNodeLinks(declaration).isVisible = true;
10392-
}
10393-
else {
10394-
result = result || [];
10395-
pushIfUnique(result, resultNode);
10396-
}
10397-
10398-
if (isInternalModuleImportEqualsDeclaration(declaration)) {
10399-
// Add the referenced top container visible
10400-
const internalModuleReference = declaration.moduleReference as Identifier | QualifiedName;
10401-
const firstIdentifier = getFirstIdentifier(internalModuleReference);
10402-
const importSymbol = resolveName(declaration, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
10403-
if (importSymbol && visited) {
10404-
if (tryAddToSet(visited, getSymbolId(importSymbol))) {
10405-
buildVisibleNodeList(importSymbol.declarations);
10406-
}
10407-
}
10408-
}
10409-
});
10410-
}
10411-
}
1041210354

1041310355
/**
1041410356
* Push an entry on the type resolution stack. If an entry with the given target and the given property name

src/compiler/debug.ts

-9
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,6 @@ export namespace Debug {
356356
}
357357
}
358358

359-
/**
360-
* Asserts the symbol is defined and is of the right kind (originating in TSC or sample DTE depending o the test that is currently being run)
361-
* The default implementation just asserts the symbol is not null
362-
* In tests it is overridden to ensure we don't accidentally use TSC symbols in DTE
363-
*/
364-
// eslint-disable-next-line prefer-const
365-
export let assertSymbolValid = (symbol: Symbol) => {
366-
assert(symbol, "Symbol not defined");
367-
};
368359
/**
369360
* Asserts a value has the specified type in typespace only (does not perform a runtime assertion).
370361
* This is useful in cases where we switch on `node.kind` and can be reasonably sure the type is accurate, and

0 commit comments

Comments
 (0)