-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Ensure public types don't reference internal types #4021
Conversation
|
84f77fe
to
ddea796
Compare
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.
This makes sense to me. It always bugged me (I'm Svelte core, too) that some types that are used by public types were not exported or marked as internal, which doesn't make sense to me since everything that a public type uses is also public.
I think there are some things that should probably remain internal. For me the threshold isn't 'is this a transitive dependency of a public type?', it's 'would I ever need to import it?'. For example utilities like export type ResolveOptions = Partial<RequiredResolveOptions>; ...but at no point would you need to use it. (We could maybe flip it around and have Of course, there is a case for documenting some of the internal types, even if we don't make them public. For example it's good to know what's available on It's worth being conservative about this — once something is a public type we can't amend or remove it without a major version bump. |
ddea796
to
44226e8
Compare
44226e8
to
b331480
Compare
b331480
to
a1db92b
Compare
4aba92f
to
1debb04
Compare
1debb04
to
1c20474
Compare
1c20474
to
a4b43cf
Compare
a4b43cf
to
c51abc7
Compare
c51abc7
to
e3e7252
Compare
09b5658
to
2496d86
Compare
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.
when I suggested documenting internal types without making them public, I didn't mean putting them in index.d.ts
but not exporting them. i think they should still live in a separate module, perhaps utils.d.ts
or something
@@ -94,7 +94,7 @@ export async function respond(request, options, state = {}) { | |||
rawBody: body_getter | |||
}); | |||
|
|||
/** @type {import('types').RequiredResolveOptions} */ | |||
/** @type {Required<import('types').ResolveOptions>} */ |
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.
since this is used in a bunch of places perhaps it would make sense to have a RequiredResolveOptions
type in internal.d.ts
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'd thought about it, but it only saves two characters and adds a layer of indirection, so is it even worth it?
I got rid of the
What's the difference between the two approaches? They seem equivalent to me. Putting it in |
You can rename and remove them, that's the whole point! |
I'm rather confused about what you're suggesting. Are you saying that adapters should not call It seems to me like we'd just be covering our eyes and ears to the fact that we're making breaking changes. Things like |
Ah, I see what you mean now. I thought you were saying that you couldn't rename it to My main concern is that we need to differentiate public types from semi-public types in the docs — at the moment the only difference between (Arguably |
I took a brief look at separating the exported and non-exported types and it's not super obvious to me how I'd do it. I updated the wording so that it's accurate now. Feel free to take this over if you'd still like to separate them. I don't have much of a preference for whether it's done by omitting the |
Closing in favor or #4104 |
This helps with #4011. Right now there are a lot of references to types that aren't documented which makes things hard to follow in some cases
If we wanted to enforce this we could (#4020), but I'm not sure that we'll need to