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(typescript-estree): support declare and export modifiers for nested namespace declaration #7410

Merged
merged 8 commits into from Aug 10, 2023

Conversation

sosukesuzuki
Copy link
Contributor

@sosukesuzuki sosukesuzuki commented Aug 4, 2023

PR Checklist

Overview

Support following syntax:

declare namespace foo.bar {}
export namespace foo.bar {}
export declare namespace foo.bar {}

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @sosukesuzuki!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@netlify
Copy link

netlify bot commented Aug 4, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 6bfd606
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/64d48bb2c131c70008845015
😎 Deploy Preview https://deploy-preview-7410--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -2901,6 +2903,7 @@ export class Converter {
node.body.name
) {
node = node.body;
isDeclare ||= hasModifier(SyntaxKind.DeclareKeyword, node);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this is needed. It may be enough to check once at the top level?

@nx-cloud
Copy link

nx-cloud bot commented Aug 4, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 6bfd606. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 37 targets

Sent with 💌 from NxCloud.

@sosukesuzuki sosukesuzuki changed the title typescript-estree: support declare namespace foo.bar { } fix: support declare namespace foo.bar { } Aug 4, 2023
@codecov
Copy link

codecov bot commented Aug 4, 2023

Codecov Report

Merging #7410 (6bfd606) into main (49e5dd5) will decrease coverage by 0.09%.
The diff coverage is 0.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7410      +/-   ##
==========================================
- Coverage   87.42%   87.34%   -0.09%     
==========================================
  Files         381      381              
  Lines       13324    13336      +12     
  Branches     3939     3943       +4     
==========================================
- Hits        11649    11648       -1     
- Misses       1297     1308      +11     
- Partials      378      380       +2     
Flag Coverage Δ
unittest 87.34% <0.00%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
packages/typescript-estree/src/convert.ts 29.83% <0.00%> (-0.21%) ⬇️
packages/typescript-estree/src/node-utils.ts 54.00% <0.00%> (-2.25%) ⬇️

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

thanks for looking into this!
looks like the logic isn't right still

end: { column: 28, line: 1 },
},
},
declare: false,
Copy link
Member

@bradzacher bradzacher Aug 5, 2023

Choose a reason for hiding this comment

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

this should be true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I've fixed f43949d and updated snapshots e8463d2

@EchoZhaoH
Copy link

The export keyword also needs to support

@bradzacher
Copy link
Member

bradzacher commented Aug 7, 2023

Oof yeah it looks like our handling is pretty shoddy overall:

declare namespace foo1 { } // ✅ declare: true
declare module foo2 { } // ✅ declare: true

declare namespace foo3.bar { } // ❌ declare: false
declare module foo4.def { } // ✅ declare: true

export declare namespace foo5 { } // ✅ export: "true"
                                  // ✅ declare: true
export declare module foo6 { } // ✅ export: "true"
                               // ✅ declare: true

export declare namespace foo7.bar { } // ❌ export: "false"
                                      // ❌ declare: false
export declare module foo8.def { } // ✅ export: "true"
                                   // ✅ declare: true

declare global { } // ✅ declare: true
                   // ✅ global: true
export declare global { } // ✅ export: "true"
                          // ✅ declare: true
                          // ✅ global: true

playground

If possible - can we add cases for and fix all of this at once?

@bradzacher bradzacher added bug Something isn't working awaiting response Issues waiting for a reply from the OP or another party labels Aug 7, 2023
@sosukesuzuki sosukesuzuki changed the title fix: support declare namespace foo.bar { } fix: support declare and export modifiers for nested namespace declaration Aug 10, 2023
@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Aug 10, 2023
@sosukesuzuki
Copy link
Contributor Author

Hmm, codecov is also failing in the part that should have been tested. Am I wrong..?

@bradzacher
Copy link
Member

nah our codecov setup just isn't able to collect coverage across packages right now, sadly.

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

thanks so much for fixing this - this fix LGTM!

@bradzacher bradzacher changed the title fix: support declare and export modifiers for nested namespace declaration fix(typescript-estree): support declare and export modifiers for nested namespace declaration Aug 10, 2023
@bradzacher bradzacher merged commit 49a53f0 into typescript-eslint:main Aug 10, 2023
47 of 50 checks passed
@sosukesuzuki sosukesuzuki deleted the fix-7409 branch August 10, 2023 14:28
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: typescript-estree does not support declare namespace foo.bar {}
3 participants