Skip to content

Commit a9d06d7

Browse files
Merge pull request #138 from bloomberg/isolated-declaration-reuse-binder
Remove binder from transpileDeclaration implementation.
2 parents 418f975 + dc1ffe9 commit a9d06d7

30 files changed

+1896
-1716
lines changed

src/compiler/_namespaces/ts.ts

Lines changed: 0 additions & 1 deletion
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

Lines changed: 90 additions & 624 deletions
Large diffs are not rendered by default.

src/compiler/debug.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
AssertionLevel,
55
BigIntLiteralType,
66
CheckMode,
7+
Comparer,
78
compareValues,
89
EmitFlags,
910
every,
@@ -356,15 +357,6 @@ export namespace Debug {
356357
}
357358
}
358359

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-
};
368360
/**
369361
* Asserts a value has the specified type in typespace only (does not perform a runtime assertion).
370362
* This is useful in cases where we switch on `node.kind` and can be reasonably sure the type is accurate, and
@@ -395,18 +387,18 @@ export namespace Debug {
395387
* Formats an enum value as a string for debugging and debug assertions.
396388
*/
397389
export function formatEnum(value = 0, enumObject: any, isFlags?: boolean) {
398-
const members = getEnumMembers(enumObject);
390+
const members = getEnumMembers(enumObject, isFlags);
399391
if (value === 0) {
400392
return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
401393
}
402394
if (isFlags) {
403395
const result: string[] = [];
404396
let remainingFlags = value;
405397
for (const [enumValue, enumName] of members) {
406-
if (enumValue > value) {
398+
if (enumValue > remainingFlags) {
407399
break;
408400
}
409-
if (enumValue !== 0 && enumValue & value) {
401+
if (enumValue !== 0 && enumValue & remainingFlags) {
410402
result.push(enumName);
411403
remainingFlags &= ~enumValue;
412404
}
@@ -427,7 +419,7 @@ export namespace Debug {
427419

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

430-
function getEnumMembers(enumObject: any) {
422+
function getEnumMembers(enumObject: any, isFlags?: boolean) {
431423
// Assuming enum objects do not change at runtime, we can cache the enum members list
432424
// to reuse later. This saves us from reconstructing this each and every time we call
433425
// a formatting function (which can be expensive for large enums like SyntaxKind).
@@ -444,7 +436,10 @@ export namespace Debug {
444436
}
445437
}
446438

447-
const sorted = stableSort<[number, string]>(result, (x, y) => compareValues(x[0], y[0]));
439+
const comparer: Comparer<[number, string]> = isFlags ?
440+
(x, y) => compareValues(x[0] >>> 0, y[0] >>> 0) :
441+
(x, y) => compareValues(x[0], y[0]);
442+
const sorted = stableSort(result, comparer);
448443
enumMemberCache.set(enumObject, sorted);
449444
return sorted;
450445
}

0 commit comments

Comments
 (0)