Skip to content

Commit 202d522

Browse files
Changed null context to have all methods from the regular transformation context.
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
1 parent a3a5049 commit 202d522

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/compiler/transformer.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,8 @@ export function transformNodes<T extends Node>(resolver: EmitResolver | undefine
666666
}
667667
}
668668

669-
// NullTransformationContext does not have all members of TransformationContext and nullTransformationContext should only be used as a CoreTransformationContext
670-
// To ensure backward compatibility, nullTransformationContext will continue to have all members of TransformationContext (with unsupported methods throwing errors)
671-
const _nullTransformationContext: Omit<TransformationContext, 'kind'> & { kind: TransformationContextKind.NullContext } = {
669+
/** @internal */
670+
export const nullTransformationContext: NullTransformationContext = {
672671
kind: TransformationContextKind.NullContext,
673672
factory: factory, // eslint-disable-line object-shorthand
674673
getCompilerOptions: () => ({}),
@@ -697,6 +696,3 @@ const _nullTransformationContext: Omit<TransformationContext, 'kind'> & { kind:
697696
onEmitNode: noEmitNotification,
698697
addDiagnostic: noop,
699698
};
700-
701-
/** @internal */
702-
export const nullTransformationContext: NullTransformationContext = _nullTransformationContext

src/compiler/types.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -9276,8 +9276,14 @@ export interface IsolatedTransformationContext extends CoreTransformationContext
92769276
addDiagnostic(diag: Diagnostic): void;
92779277
}
92789278
/** @internal */
9279-
export interface NullTransformationContext extends CoreTransformationContext {
9279+
export interface NullTransformationContext extends Omit<TransformationContext, 'kind'> {
92809280
kind: TransformationContextKind.NullContext;
9281+
getEmitResolver(): never;
9282+
getEmitHost(): never;
9283+
getEmitHelperFactory(): never;
9284+
readEmitHelpers(): never;
9285+
isSubstitutionEnabled(): never;
9286+
isEmitNotificationEnabled(): never;
92819287
}
92829288

92839289
export interface TransformationResult<T extends Node> {

0 commit comments

Comments
 (0)