diff --git a/tests/misc/errors/typescript/babel-ts/__snapshots__/jsfmt.spec.js.snap b/tests/misc/errors/typescript/babel-ts/__snapshots__/jsfmt.spec.js.snap index 3c2c892eb576..7ad575c2f16c 100644 --- a/tests/misc/errors/typescript/babel-ts/__snapshots__/jsfmt.spec.js.snap +++ b/tests/misc/errors/typescript/babel-ts/__snapshots__/jsfmt.spec.js.snap @@ -16,6 +16,16 @@ exports[`classAbstractMethodWithImplementation.ts [babel-ts] format 1`] = ` 3 | }" `; +exports[`declare-accessor.ts [babel-ts] format 1`] = ` +"'declare' is not allowed in getters. (2:3) + 1 | class Foo { +> 2 | declare get foo() + | ^ + 3 | declare set foo(v) + 4 | } + 5 |" +`; + exports[`snippet: #0 [babel-ts] format 1`] = ` "Invalid left-hand side in assignment expression (1:1) > 1 | foo as any = 10; diff --git a/tests/misc/errors/typescript/babel-ts/declare-accessor.ts b/tests/misc/errors/typescript/babel-ts/declare-accessor.ts new file mode 100644 index 000000000000..6ca324a281db --- /dev/null +++ b/tests/misc/errors/typescript/babel-ts/declare-accessor.ts @@ -0,0 +1,4 @@ +class Foo { + declare get foo() + declare set foo(v) +} diff --git a/tests/typescript/declare/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/declare/__snapshots__/jsfmt.spec.js.snap index fe39e136e522..d6699d8ac817 100644 --- a/tests/typescript/declare/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/declare/__snapshots__/jsfmt.spec.js.snap @@ -195,3 +195,23 @@ declare const hello2 = 5; ================================================================================ `; + +exports[`declare-get-set-field.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +class C { + declare get: string + declare set: string; +} + +=====================================output===================================== +class C { + declare get: string; + declare set: string; +} + +================================================================================ +`; diff --git a/tests/typescript/declare/declare-get-set-field.ts b/tests/typescript/declare/declare-get-set-field.ts new file mode 100644 index 000000000000..fe1189b6ea44 --- /dev/null +++ b/tests/typescript/declare/declare-get-set-field.ts @@ -0,0 +1,4 @@ +class C { + declare get: string + declare set: string; +}