Skip to content

Commit

Permalink
fix: add decoratorAutoAccessors plugin (#594)
Browse files Browse the repository at this point in the history
* fix: add decoratorAutoAccessors plugin

* test: add test for decorator auto accessor

* move test into src
  • Loading branch information
syi0808 authored Jul 30, 2024
1 parent 80d46fa commit 36aab12
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/docs/
/test/
/sample/
/recipes/
.gitignore
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
},
"jest": {
"roots": [
"test",
"src",
"bin",
"parser",
Expand Down
1 change: 1 addition & 0 deletions parser/__tests__/__snapshots__/tsx-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`tsxParser parse extends the ts config with jsx support 1`] = `
"plugins": [
"jsx",
"asyncGenerators",
"decoratorAutoAccessors",
"bigInt",
"classPrivateMethods",
"classPrivateProperties",
Expand Down
1 change: 1 addition & 0 deletions parser/tsOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
tokens: true,
plugins: [
'asyncGenerators',
'decoratorAutoAccessors',
'bigInt',
'classPrivateMethods',
'classPrivateProperties',
Expand Down
26 changes: 26 additions & 0 deletions src/__tests__/ts-decorator-auto-accessor-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

function transformer(file, api) {
const j = api.jscodeshift;

return j(file.source).toSource();
}

transformer.parser = 'ts';

jest.autoMockOff();
const defineInlineTest = require('../../src/testUtils').defineInlineTest;

describe('should be parse typescript decoratorAutoAccessors correctly', function () {
defineInlineTest(
transformer,
{},
'export class Test {\n' +
' public accessor myValue = 10;\n' +
'}\n',
'export class Test {\n' +
' public accessor myValue = 10;\n' +
'}',
'ts-decorator-auto-accessor',
);
});

0 comments on commit 36aab12

Please sign in to comment.