Skip to content

Commit 56098f3

Browse files
Added back runtime members to nullTransformationContext
1 parent c45ffaf commit 56098f3

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/compiler/transformer.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
NodeFactory,
4040
NodeFlags,
4141
noop,
42+
notImplemented,
4243
NullTransformationContext,
4344
returnUndefined,
4445
ScriptTarget,
@@ -665,11 +666,15 @@ export function transformNodes<T extends Node>(resolver: EmitResolver | undefine
665666
}
666667
}
667668

668-
/** @internal */
669-
export const nullTransformationContext: NullTransformationContext = {
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 } = {
670672
kind: TransformationContextKind.NullContext,
671673
factory: factory, // eslint-disable-line object-shorthand
672674
getCompilerOptions: () => ({}),
675+
getEmitResolver: notImplemented,
676+
getEmitHost: notImplemented,
677+
getEmitHelperFactory: notImplemented,
673678
startLexicalEnvironment: noop,
674679
resumeLexicalEnvironment: noop,
675680
suspendLexicalEnvironment: noop,
@@ -682,4 +687,16 @@ export const nullTransformationContext: NullTransformationContext = {
682687
startBlockScope: noop,
683688
endBlockScope: returnUndefined,
684689
addBlockScopedVariable: noop,
690+
requestEmitHelper: noop,
691+
readEmitHelpers: notImplemented,
692+
enableSubstitution: noop,
693+
enableEmitNotification: noop,
694+
isSubstitutionEnabled: notImplemented,
695+
isEmitNotificationEnabled: notImplemented,
696+
onSubstituteNode: noEmitSubstitution,
697+
onEmitNode: noEmitNotification,
698+
addDiagnostic: noop,
685699
};
700+
701+
/** @internal */
702+
export const nullTransformationContext: NullTransformationContext = _nullTransformationContext

0 commit comments

Comments
 (0)