@@ -39,7 +39,7 @@ export function extractHmrDependencies(
3939) : {
4040 local : { name : string ; runtimeRepresentation : o . Expression } [ ] ;
4141 external : R3HmrNamespaceDependency [ ] ;
42- } {
42+ } | null {
4343 const name = ts . isClassDeclaration ( node ) && node . name ? node . name . text : null ;
4444 const visitor = new PotentialTopLevelReadsVisitor ( ) ;
4545 const sourceFile = node . getSourceFile ( ) ;
@@ -70,10 +70,13 @@ export function extractHmrDependencies(
7070 const readName = readNode instanceof o . ReadVarExpr ? readNode . name : readNode . text ;
7171
7272 if ( readName !== name && ! seenLocals . has ( readName ) && availableTopLevel . has ( readName ) ) {
73- local . push ( {
74- name : readName ,
75- runtimeRepresentation : getRuntimeRepresentation ( readNode , reflection , evaluator ) ,
76- } ) ;
73+ const runtimeRepresentation = getRuntimeRepresentation ( readNode , reflection , evaluator ) ;
74+
75+ if ( runtimeRepresentation === null ) {
76+ return null ;
77+ }
78+
79+ local . push ( { name : readName , runtimeRepresentation} ) ;
7780 seenLocals . add ( readName ) ;
7881 }
7982 }
@@ -94,7 +97,7 @@ function getRuntimeRepresentation(
9497 node : o . ReadVarExpr | ts . Identifier ,
9598 reflection : ReflectionHost ,
9699 evaluator : PartialEvaluator ,
97- ) : o . Expression {
100+ ) : o . Expression | null {
98101 if ( node instanceof o . ReadVarExpr ) {
99102 return o . variable ( node . name ) ;
100103 }
@@ -120,6 +123,11 @@ function getRuntimeRepresentation(
120123 quoted : false ,
121124 value : o . literal ( value . resolved ) ,
122125 } ) ;
126+ } else {
127+ // TS is pretty restrictive about what values can be in a const enum so our evaluator
128+ // should be able to handle them, however if we happen to hit such a case, we return null
129+ // so the HMR update can be invalidated.
130+ return null ;
123131 }
124132 }
125133
0 commit comments