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

Enable parsing of accessor keyword #580

Open
RhodeHummel opened this issue Jan 5, 2024 · 6 comments
Open

Enable parsing of accessor keyword #580

RhodeHummel opened this issue Jan 5, 2024 · 6 comments

Comments

@RhodeHummel
Copy link

It looks like jscodeshift does not currently support the accessor keyword that was added typescript in 3.9. Can we please add support for this. Thank you.

microsoft/TypeScript#49705
https://github.com/tc39/proposal-decorators

@RhodeHummel RhodeHummel changed the title Enable parsing of new accessor keyword Enable parsing of accessor keyword Jan 5, 2024
@RhodeHummel RhodeHummel changed the title Enable parsing of accessor keyword Enable parsing of accessor keyword Jan 5, 2024
@ElonVolo
Copy link
Collaborator

ElonVolo commented Jan 5, 2024

Would you be able to add the content you were trying to transform, the transformation script you wrote, the command you ran to transform it, and the expected output, to the issue?

@Daniel15
Copy link
Member

Daniel15 commented Jan 11, 2024

I think this will need upstream changes (recast and/or ast-types)

@RhodeHummel
Copy link
Author

RhodeHummel commented Jan 11, 2024

@ElonVolo Here is a simple case. Basically, I just want it to run without any errors. Hope this is enough information for you.

// test-file.ts
export class Test {
    public accessor myValue = 10;
}
// test-transform.ts
import { FileInfo, API, Options } from 'jscodeshift';

module.exports = function (file: FileInfo, { j }: API, _options: Options) {
    const root = j(file.source);

    // Do nothing just output the file again
    return root.toSource();
};

BTW: I noticed that this is already supported by babel but the plugin for it does need to be configured. Could that be the problem in this case?

@ElonVolo
Copy link
Collaborator

ElonVolo commented Jan 11, 2024

I'm running the transform and file code you submitted and I'm not getting any errors. Nothing's being transformed, which is expected as no modifications have been made.

Are you getting some different result on your end?

@ElonVolo
Copy link
Collaborator

I think this will need upstream changes (recast and/or ast-types)

I looked at the recast code and there does seem to be some support for Typescript's accessor keyword.

@RhodeHummel
Copy link
Author

@ElonVolo I definitely get an error. There is no error message, it just prints out results 1 error instead of 1 unmodified. I have created an isolated test case and included it here.

To see the error, run npx ts-node test.ts

jscodeshift-error.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants