-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
TypeScript-specific feedback & thoughts #3
Comments
I'm a bit confused because currently D comes before P. Are you suggesting that Props should come before Data, or the other way around?
I guess it should default to
Yeah this part is very much just a proof of concept right now. We will revisit proper typing for it when we finalize it. The
Good to know, I wasn't aware of API extractor before. Will look into it.
|
Whoops! Fixed. Yes, I meant
I think that users looking for Vue/TypeScript will prefer the stricter experience. Even so, if we can do some more inference here that will probably strike a better balance of writing less while still getting better types. I've opened up microsoft/TypeScript#27584 so we can track that.
That sounds reasonable to me, though I'm wondering if the idea is to just have two separate builds, or if the Vue 2.x functionality is available out of the box.
That's basically it, but I wouldn't get hyper-focused on that if it's not a problem. It can just give you faster builds; if |
|
Actually, I realized that props are specified statically (as they should be), not via a |
When a component doesn't declare props, the consumer of the component can pass arbitrary props to it that may conflict with the component's own data or methods. With declared props we can check duplication and warn at development time. |
Closing since we are dropping the Class API. |
I'd like to keep the other breaking changes feedback thread scoped to breaking changes. Here's some TypeScript-specific feedback which doesn't need to be addressed immediately, but which stood out to me while exploring the package.
Generic type parameter for props (
P
) should come before data (D
)This was the biggest footgun I made when I worked on the Vue
.d.ts
files the first time. I specifiedProps
first rather thanData
and I believe that Vue 3.0 shouldn't make the same mistake. When it comes to components, almost all of them will use props and have a harder time specifying them than data.Generic type parameter
P
has defaultsThere are a lot of instances of
P = Data
(which is really justP = Record<string, any>
). Is there any reason that's necessary? I feel like the class-based API doesn't really need this since, on the whole, it's mostly inferred, though I could be missing something.Vue
is currently non-genericVue
(frompackages/vue
) currently has a different API thanComponent
(frompackages/core
). Specifically,Vue
is generic and seems to be the "full-featured" version of the component. You already mentioned that things are in a state of progress, but is the difference mostly about mount points depending on target runtimes (i.e. DOM vs. native vs. ...)?.d.ts
files are produced using dts-bundledts-bundle throws all of your modules into a single global file with several ambient module declarations. The problem with ambient module declarations is that they are in the global scope in the first place. If you have multiple versions of Vue loaded up by a project (via a separate dependency probably), then two ambient modules for the path
@vue/renderer-dom
can conflict, which can cause problems.Mitigations
We should consider looking into API Extractor to produce
.d.ts
files that describe top-level APIs for Vue.Build process could leverage project references.
Right now it appears that there's a custom TypeScript build that happens, and it seems like that's an all-or-nothing approach. Depending on whether build times are an issue, we could potentially leverage project references. If there's a reason you can't use them, it'd be helpful for our team to get an idea of the challenges. 😃
The text was updated successfully, but these errors were encountered: