Skip to content
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

AssignIn returns wrong type #259

Open
HaimWix opened this issue May 3, 2020 · 2 comments
Open

AssignIn returns wrong type #259

HaimWix opened this issue May 3, 2020 · 2 comments
Assignees

Comments

@HaimWix
Copy link
Contributor

HaimWix commented May 3, 2020

type SomeObject = {
	someField: string
}
function changeSomeField(carmiObject: Graph<SomeObject, F>) {
	carmiObject.assignIn([{someField: {extraProp: true}}])
	carmiObject.get('someField') --TYPE--> Graph<string & {extraProp: boolean}>
}

There are some examples online for a better typing though it's not complete as well

@nirnatan
Copy link
Collaborator

nirnatan commented May 4, 2020

Do you have a real use case? It looks like the problem is only when you try to assign two object that has the same property with different type i.e. {a: number} and {a: string}

@HaimWix
Copy link
Contributor Author

HaimWix commented May 4, 2020

Yes, it happens when you want to merge two objects that has different types for same fields.
The use case I had was for replacing breakpoint field
{breakpoint : string, ...rest}
to
{breakpoint: {range: {min:number, max:number}, mediaQuery} ...rest

I no longer intend to write this code, but I think it's a valid case though not common

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants