-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: add .kind
to TSModuleDeclaration
#6443
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
Conversation
Thanks for the PR, @bradzacher! 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. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Love you, man. |
I'm not familiar with TypeScript. Just a reminder, do you know Have you thought about how these two will work once TypeScript support it? Should we wrap body in |
Yeah it's a "program". Semantically there's a few declarations that aren't allowed inside of a TSModuleDeclaration that are allowed within a Program body. At some point we might make them syntax errors. I assume that a module expression will be the same as a fully-fledged Program with no restrictions. |
I think "ModuleExpression" need update anyway estree/estree#238 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! 🚀
} | ||
if (id.type !== AST_NODE_TYPES.Identifier) { | ||
throw new Error('`namespace`s must have an Identifier id'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just note that #6247 adds an option to throw or not throw on these errors. Potential merge conflict in the making.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah these errors are just there for fun tbh.
I actually could have left it all typed as any
(which is what converChild
returns). But I added slightly stricter checks just because.
But these constrains are all actually covered by syntax checks in TS itself so they won't ever get hit.
Also - this is waiting until your migration PR lands so I don't need to make changes to the old test infra. |
e7435fc
to
e020917
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6443 +/- ##
==========================================
- Coverage 90.66% 90.61% -0.06%
==========================================
Files 371 371
Lines 12664 12677 +13
Branches 3722 3728 +6
==========================================
+ Hits 11482 11487 +5
- Misses 845 853 +8
Partials 337 337
Flags with carried forward coverage won't be shown. Click here to find out more.
|
PR Checklist
TSModuleDeclaration
#6440Overview
The primary change in this PR is the addition of the new
.kind
property toTSModuleDeclaration
to help consumers identify what keyword was used to declare the module declaration.With the addition of this property it also allowed me to provide better union types to clearly define when a module might be missing a body, have a string id, etc.
cc @fisker