Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

fix: wrap interface in ExportNamedDeclaration if necessary (fixes #269 #270

Merged
merged 1 commit into from
May 20, 2017

Conversation

despairblue
Copy link
Contributor

No description provided.

@eslintbot
Copy link

Thanks for the pull request, @despairblue! I took a look to make sure it's ready for merging and found some changes are needed:

  • The commit summary needs to begin with a tag (such as Fix: or Update:). Please check out our guide for how to properly format your commit summary and update it on this pull request.

  • Pull requests with code require an issue to be mentioned at the end of the commit summary, such as (fixes #1234). Please update the commit summary with an issue (file a new issue if one doesn't already exist).

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@despairblue despairblue force-pushed the fix/ts-interface-declaration branch from 713a5cc to b4283af Compare May 13, 2017 15:29
@eslintbot
Copy link

LGTM

Copy link
Member

@soda0289 soda0289 left a comment

Choose a reason for hiding this comment

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

Can you use fixExports() from nodeUtils. It will wrap the node in export and handles default case as well. Take a look at function declaration or class declaration for examples.

To check if an interface is abstract:
nodeUtils.hasModifier(SyntaxKind.AbstractKeyword, node) Should do the trick. I think we can just have a property called abstract.

Thanks

@despairblue despairblue force-pushed the fix/ts-interface-declaration branch from b4283af to 9b1a98a Compare May 13, 2017 16:39
@eslintbot
Copy link

LGTM

@despairblue
Copy link
Contributor Author

@soda0289 done.

The diffs for the other tests are a bit bigger because I used tools/update-typescript-tests.js to generate them. I also fixed tools/update-typescript-tests.js to use the same getRaw implementation the tests use and added a missing shelljs.echo call.

Abstract interfaces are not valid TypeScript btw. But I think they added the test to make sure the parser can handle that, so they can output a useful error message like 'abstract' modifier can only appear on a class, method, or property declaration. instead of Expected ClASS or STRING. Instead found ABSTRACT.

@soda0289
Copy link
Member

soda0289 commented May 13, 2017

@despairblue Thanks for making the changes.

If abstract interfaces are not valid typescript I'm not sure we should support them or the very least only set abstract: true when it is present and not set abstract: false. I'll let @JamesHenry review just to make sure this change makes sense.

@soda0289 soda0289 requested a review from JamesHenry May 13, 2017 19:31
@despairblue
Copy link
Contributor Author

I'm happy with whatever choice you make.

That said, my understanding is that this is an AST to AST converter, so it should convert the AST as accurately as possible and should not make assumptions about it's semantics as a program.

But again, it's your choice, we just would need to blacklist some tests from the typescript test suite, no biggie :)

@despairblue
Copy link
Contributor Author

@soda0289 @JamesHenry is there anything I can do to help this get in? I could remove the abstract if that's the problem.

@soda0289
Copy link
Member

I'm fine with using abstract. I think we are also going to change classes to use a property abstract now as well instead of a new node type. I will merge this soon.

@soda0289
Copy link
Member

@despairblue There will be quite a few changes coming to the AST as we try to align with the AST from the new typescript babylon plugin. You can check the issues here:
https://github.com/JamesHenry/tsep-babylon-test/issues

@soda0289 soda0289 merged commit 3f9f41c into eslint:master May 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants