From 0c3f381198a191a9d3b6ecb422f69dc0e81afb77 Mon Sep 17 00:00:00 2001 From: ota-meshi Date: Sun, 28 May 2023 18:43:41 +0900 Subject: [PATCH] fix: to raise error in escaped static method --- __test__/class/type.test.ts | 13 ++++++++++++- src/index.ts | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/__test__/class/type.test.ts b/__test__/class/type.test.ts index f16a6f0..9c7ae7e 100644 --- a/__test__/class/type.test.ts +++ b/__test__/class/type.test.ts @@ -148,6 +148,17 @@ describe('class', () => { equalNode(node, ClassTypeSnapshot.StaticGetterSetter) }) + it('escaped static method ', () => { + // See: https://github.com/tc39/test262/blob/main/test/language/statements/class/syntax/escaped-static.js + expect(() => { + parseSource(generateSource([ + `class C {`, + ` st\\u0061tic m() {}`, + `}` + ])) + }).toThrowError() + }) + it('private class method', () => { const node = parseSource(generateSource([ `class Student {`, @@ -278,7 +289,7 @@ describe('class', () => { equalNode(node, ClassTypeSnapshot.Accessor) }) - it.only('escaped keyword property ', () => { + it('escaped keyword property ', () => { const node = parseSource(generateSource([ `class C {`, ` \\u0069n: string`, diff --git a/src/index.ts b/src/index.ts index df3f2ff..9b44f18 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2139,7 +2139,7 @@ function tsPlugin(options?: { } const modifier = this.value as any - if (allowedModifiers.indexOf(modifier) !== -1) { + if (allowedModifiers.indexOf(modifier) !== -1 && !this.containsEsc) { if (stopOnStartOfClassStaticBlock && this.tsIsStartOfStaticBlocks()) { return undefined }