Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add decoratorAutoAccessors plugin #594

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -61,6 +61,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' +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use template strings to avoid the concatenation, but we can change it separately :)

' public accessor myValue = 10;\n' +
'}\n',
'export class Test {\n' +
' public accessor myValue = 10;\n' +
'}',
'ts-decorator-auto-accessor',
);
});