Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat(eslint-plugin): [require-types-exports] add new rule #8443
base: main
Are you sure you want to change the base?
feat(eslint-plugin): [require-types-exports] add new rule #8443
Changes from 31 commits
9a0c28a
7778868
12fce5b
d62f86c
0ebebd2
30e9aa9
bfee791
b309b51
6aa6446
892c368
0e8e58f
f4018a8
89a8344
b2138e3
feedefd
1161db0
d9875b3
6338202
428b2c1
2cb3455
1812e37
4bee779
26e7be7
e57985a
cbb784c
2f2dfa4
37a0171
6fb274a
4672fe1
c79b5cb
279055a
7897abf
7082960
2f81933
0f788d2
6cec0f5
497957a
702d4d0
700ff85
9a155b3
8d0d000
b65f9c4
078e24a
ed23162
ac224eb
417cc91
62f1466
ae1b87c
d227408
dca52d0
ed30856
15fc51c
59eda58
fc0858a
9d24c64
94a98eb
dee0fe4
0804b24
a0a4944
66a0aff
b67e1f9
9891e78
cb90d43
479f593
08f2ce2
e86427f
a61d49f
121f475
f3f8518
ab837b4
1641272
fd56a1c
b0613d5
b9f1148
0415b60
a0c236e
3d5d695
2e76ce6
88713cb
ff2c0a8
2fd30aa
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
From #8443 (comment):
That file's
.d.ts
equivalent is:...so it should only report
A
andC
as needing to be exported, no? Am I missing something?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, sorry, I've mistyped the type names there, it should be A & C as you said,
Anyway... I didn't explain myself properly (it was after a lot of work on this, my brain basically melted 🧠)
Because I need to somehow follow the whole path of the
MemberExpression
and try to infer its value from the root object. Maybe that's fine and easy and I'm just making it hard in my mind? 🤷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.
Indeed. I think this is going to need recursive logic to traverse through object literals like that.
I'd think so. I don't think we should care about what a
type
's actual type is - just that it's exported. We'd certainly want to report in this case: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.
Not sure whether I understand the difference here
If the type is an alias to a built-in primitive type we shouldn't report, and if it's an object or something we should?
I mean... yeah, TS won't emit
A
in the.d.ts
file in my example, so if I understand you correctly, I'll need to re-create TS's logic here about whether a type should appear in the function's declaration, right?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.
Not that, I'm suggesting the opposite. What I'm proposing is: any
type
that's visible in other exports should be exported itself. That would hold true forstring
,number | string
,(number | string)[]
,{ inner: string }
, etc.I'm suggesting this in part to try to make this rule easier to implement and maintain 😄. Having to determine whether some
type
is emitted is more work.But also, folks sometimes use
type
s for opaque values:In this case, I think it'd match the intent of the rule to say
Id
should be exported....but anyway, what I'm trying to suggest here is the simplest approach: if something declared in the AST is used in an export, we assume it should be exported.
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.
Ok, that's exactly what I thought!
Now I realize that I'm stupid and misunderstood you
You said "I think so", while I read it (for some reason...) "I think no" - totally different meaning 😅
Yeah, that's much easier
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.
[Docs] What do you think of this, for a more informative error?
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 like it
Done