diff --git a/src/processing/script/transformers/location-get.ts b/src/processing/script/transformers/location-get.ts index 3f366ffd9..95f81d944 100644 --- a/src/processing/script/transformers/location-get.ts +++ b/src/processing/script/transformers/location-get.ts @@ -68,6 +68,11 @@ const transformer: Transformer = { if (parent.type === Syntax.MethodDefinition) return false; + // Skip: class X { location } + // @ts-ignore + if (parent.type === Syntax.PropertyDefinition) + return false; + // Skip: class location { x () {} } if (parent.type === Syntax.ClassDeclaration) return false; diff --git a/test/server/script-processor-test.js b/test/server/script-processor-test.js index 92d22ac74..73e03fef1 100644 --- a/test/server/script-processor-test.js +++ b/test/server/script-processor-test.js @@ -288,6 +288,11 @@ describe('Script processor', () => { '? function(){var _hh$temp0 = newLocation; return __set$Loc(location,_hh$temp0)||(location=_hh$temp0);}.call(this)' + ': function(){var _hh$temp1 = "#123"; return __set$Loc(location,_hh$temp1)||(location=_hh$temp1);}.call(this);', }, + { + src: 'class C { location }', + + expected: 'class C { location }', + }, { src: 'if (location) { location = newLocation; } else location = "#123";',