Skip to content

Commit 36aab12

Browse files
authored
fix: add decoratorAutoAccessors plugin (#594)
* fix: add decoratorAutoAccessors plugin * test: add test for decorator auto accessor * move test into src
1 parent 80d46fa commit 36aab12

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/docs/
2+
/test/
23
/sample/
34
/recipes/
45
.gitignore

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
},
6060
"jest": {
6161
"roots": [
62+
"test",
6263
"src",
6364
"bin",
6465
"parser",

parser/__tests__/__snapshots__/tsx-test.js.snap

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ exports[`tsxParser parse extends the ts config with jsx support 1`] = `
99
"plugins": [
1010
"jsx",
1111
"asyncGenerators",
12+
"decoratorAutoAccessors",
1213
"bigInt",
1314
"classPrivateMethods",
1415
"classPrivateProperties",

parser/tsOptions.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = {
1919
tokens: true,
2020
plugins: [
2121
'asyncGenerators',
22+
'decoratorAutoAccessors',
2223
'bigInt',
2324
'classPrivateMethods',
2425
'classPrivateProperties',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
function transformer(file, api) {
4+
const j = api.jscodeshift;
5+
6+
return j(file.source).toSource();
7+
}
8+
9+
transformer.parser = 'ts';
10+
11+
jest.autoMockOff();
12+
const defineInlineTest = require('../../src/testUtils').defineInlineTest;
13+
14+
describe('should be parse typescript decoratorAutoAccessors correctly', function () {
15+
defineInlineTest(
16+
transformer,
17+
{},
18+
'export class Test {\n' +
19+
' public accessor myValue = 10;\n' +
20+
'}\n',
21+
'export class Test {\n' +
22+
' public accessor myValue = 10;\n' +
23+
'}',
24+
'ts-decorator-auto-accessor',
25+
);
26+
});

0 commit comments

Comments
 (0)