Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Conversation

@semoal
Copy link
Member

@semoal semoal commented May 13, 2021

https://github.com/rematch/rematch/pull/891/files#diff-1f8711ffcf4ef0b26aea69d164072937102d5109ecfd8790b6e879c7421e00d3

Since I've checked how it's the strategy with typescript and addModel, has sense to define a RootModel which is Partial of a complete RootModel.

import { Models } from '@rematch/core'
import { players } from './players'
import { settings } from './settings'
import { cart } from './cart'

export interface RootModel extends Models<RootModel> {
	players: typeof players
	cart: typeof cart
	settings: typeof settings
}

export const models: Partial<RootModel> = { players, cart }

In this way we can define the complete typings but a FUTURE usage, but the current models isn't complete yet.

@semoal semoal requested a review from tianzhich May 13, 2021 21:20
@github-actions
Copy link

size-limit report 📦

Path Size
./packages/core/dist/core.umd.production.min.js 1.42 KB (0%)
./packages/immer/dist/immer.umd.production.min.js 143 B (0%)
./packages/loading/dist/loading.umd.production.min.js 596 B (0%)
./packages/persist/dist/persist.umd.production.min.js 172 B (0%)
./packages/select/dist/select.umd.production.min.js 456 B (0%)
./packages/updated/dist/updated.umd.production.min.js 407 B (0%)

Copy link
Collaborator

@tianzhich tianzhich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still not sure why we need to partialize the defined rootModels. If we don't use this model, we should also remove its typing? Could you explain more clearly mate?

@tianzhich
Copy link
Collaborator

I seem to understand your opinion. Do you want to fix the dynamically added model's typing problem? I guess you want to define it's types before you add it dynamically. So there will no typing problem after it is added. Am I right?

@semoal
Copy link
Member Author

semoal commented May 14, 2021

I seem to understand your opinion. Do you want to fix the dynamically added model's typing problem? I guess you want to define it's types before you add it dynamically. So there will no typing problem after it is added. Am I right?

Exactly that

Copy link
Collaborator

@tianzhich tianzhich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I think that's well for dynamically adding features. Good job mate  👍

@semoal semoal changed the title fix: make models on init also Partial<T> fix: make models on init() Partial<T> May 14, 2021
@semoal semoal merged commit 991a9d8 into main May 14, 2021
@semoal semoal deleted the fix-partial branch May 14, 2021 10:53
@semoal semoal mentioned this pull request May 25, 2021
15 tasks
@tianzhich tianzhich mentioned this pull request May 26, 2021
5 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants