Skip to content

Remove binder from transpileDeclaration implementation. #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/compiler/_namespaces/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export * from "../transformers/module/system";
export * from "../transformers/module/esnextAnd2015";
export * from "../transformers/module/node";
export * from "../transformers/declarations/diagnostics";
export * from "../transformers/declarations/emitBinder";
export * from "../transformers/declarations/emitResolver";
export * from "../transformers/declarations/transpileDeclaration";
export * from "../transformers/declarations/localInferenceResolver";
Expand Down
714 changes: 90 additions & 624 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

23 changes: 9 additions & 14 deletions src/compiler/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
AssertionLevel,
BigIntLiteralType,
CheckMode,
Comparer,
compareValues,
EmitFlags,
every,
Expand Down Expand Up @@ -356,15 +357,6 @@ export namespace Debug {
}
}

/**
* 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)
* The default implementation just asserts the symbol is not null
* In tests it is overridden to ensure we don't accidentally use TSC symbols in DTE
*/
// eslint-disable-next-line prefer-const
export let assertSymbolValid = (symbol: Symbol) => {
assert(symbol, "Symbol not defined");
};
/**
* 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
Expand Down Expand Up @@ -395,18 +387,18 @@ export namespace Debug {
* Formats an enum value as a string for debugging and debug assertions.
*/
export function formatEnum(value = 0, enumObject: any, isFlags?: boolean) {
const members = getEnumMembers(enumObject);
const members = getEnumMembers(enumObject, isFlags);
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) {
if (enumValue > remainingFlags) {
break;
}
if (enumValue !== 0 && enumValue & value) {
if (enumValue !== 0 && enumValue & remainingFlags) {
result.push(enumName);
remainingFlags &= ~enumValue;
}
Expand All @@ -427,7 +419,7 @@ export namespace Debug {

const enumMemberCache = new Map<any, SortedReadonlyArray<[number, string]>>();

function getEnumMembers(enumObject: any) {
function getEnumMembers(enumObject: any, isFlags?: boolean) {
// 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).
Expand All @@ -444,7 +436,10 @@ export namespace Debug {
}
}

const sorted = stableSort<[number, string]>(result, (x, y) => compareValues(x[0], y[0]));
const comparer: Comparer<[number, string]> = isFlags ?
(x, y) => compareValues(x[0] >>> 0, y[0] >>> 0) :
(x, y) => compareValues(x[0], y[0]);
const sorted = stableSort(result, comparer);
enumMemberCache.set(enumObject, sorted);
return sorted;
}
Expand Down
Loading