Comments (6)
Generic type parameter for props (P) comes before data (D)
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?
Generic type parameter P has defaults
I guess it should default to {}
instead. I gave it the Record<string, any>
default mostly so that I can omit the generics and get a magical this
when I don't want to bother with specifying types. Changing to to {}
would force users to always fully type their props. It may be a bit too strict but maybe that's a good idea.
Vue
is currently non-generic
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 vue
package will likely be just the 2.x compat build which will use the 2.x typings...
.d.ts
files are produced using dts-bundle
Good to know, I wasn't aware of API extractor before. Will look into it.
Build process could leverage project references.
I'm not sure if I understand the proposal - I haven't seen the need for project references so far. Maybe we will need it later? Are you suggesting we place a tsconfig.json
in each package and reference the root tsconfig.json
?
from core.
Generic type parameter for props (P) comes before data (D)
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?
Whoops! Fixed. Yes, I meant P
should come before D
.
Generic type parameter P has defaults
I guess it should default to
{}
instead. I gave it theRecord<string, any>
default mostly so that I can omit the generics and get a magicalthis
when I don't want to bother with specifying types. Changing to to{}
would force users to always fully type their props. It may be a bit too strict but maybe that's a good idea.
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.
Vue
is currently non-genericYeah this part is very much just a proof of concept right now. We will revisit proper typing for it when we finalize it. The
vue
package will likely be just the 2.x compat build which will use the 2.x typings...
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.
Build process could leverage project references.
I'm not sure if I understand the proposal - I haven't seen the need for project references so far. Maybe we will need it later? Are you suggesting we place a
tsconfig.json
in each package and reference the roottsconfig.json
?
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 A
depends on B depends on
C, a change to
Cthat doesn't affect its public API means that neither
Anor
B` need to be rebuilt if their outputs are built and already up-to-date.
from core.
props
duplication & validation
From #2 (comment)
A few obvious things to improve here:
1. If the user provided a Props interface but didn't specify the static props options, the props will still be merged onto `this` in types but not in implementation. 2. User has to specify the Props interface for compile-time type checking AND the props options for runtime type checking. It'd be nice if the compile-time types can be inferred from the props options like it does for 2.x, although I haven't figured out how to do that yet.
I'm a little curious over what the rationale is to only proxy specified props
. What are the current design limitations that prevent this.
Note the reason we are designing it like this is because we want to make plain ES usage and TS usage as close as possible. As you can see, an ES2015 version of the above would simply be removing the interfaces and replacing the static options with an assignment.
If we can get a decorator implementation that matches the new stage-2/3 proposal, we can provide decorators that make it simpler:
class Foo extends Component { @data foo: string = 'hello' @prop bar: number = 123 }
I agree that this'd be nice, though, the problem here is that now there's nowhere to keep track of props
externally. So while you get internal validation, there's not a way to keep track of which props
you're aggregating. I'll check with the team to get some thoughts around this.
from core.
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
Actually, I realized that props are specified statically (as they should be), not via a super()
call. So never mind that!
from core.
I'm a little curious over what the rationale is to only proxy specified props. What are the current design limitations that prevent this.
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.
from core.
Closing since we are dropping the Class API.
from core.
Related Issues (20)
- Rendering Glitches in <select> Component Options in Firefox When Using Objects as Values HOT 2
- Server performance degrades as more concurrent users hit an SSR-ed Vue app HOT 5
- 111
- Hydration node mismatch about SSR can not be clean HOT 1
- why ref in compoent get dom is empty HOT 1
- v-memo in v-for, only memoize until the first changed item HOT 1
- Import name of child component being the same as the name of the Parent triggers an infinite recursion. HOT 2
- Since vue 3.4.15 named slots not render with component same name like html tags HOT 1
- option tag re-rendering issue when :value attribute is null HOT 2
- VDOM doesn't restore selection in a text input
- Unhandled error during execution of render function HOT 1
- Cannot use :global() in scoped style in nesting rules like SCSS
- Hydration node mismatch warning will lead to error HOT 5
- Vue render option tag with empty value attribute without attribute HOT 5
- [Bug Report][3.4.20] Uncaught (in promise) TypeError: Cannot read properties of null (reading 'da') HOT 4
- how to use props to define ts class type HOT 6
- defineSlots<SlotInterface>() missing slotNames HOT 3
- SCSS v-bind doesn't work with native css darken(...) HOT 2
- isFunction is not a function at defineComponent HOT 6
- 【BUG】watch() 传入reactive类型的响应式数据,vue3.4版本与3.3/3.2表现不一致 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.