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

intersection with typescript libs #5

Closed
uittorio opened this issue Jan 19, 2019 · 4 comments
Closed

intersection with typescript libs #5

uittorio opened this issue Jan 19, 2019 · 4 comments

Comments

@uittorio
Copy link
Member

uittorio commented Jan 19, 2019

I wrote some test scenario with jasmine to simplify the explanation

describe('intersection with typescript lib', () => {
	type TypeIntersection = {} & Promise<string>;
		
	interface Intersection {
		a: TypeIntersection;
	}

	it('should be undefined', () => {
		const properties: Mock<Intersection> = createMock<Intersection>();
		expect(properties.a.then).toBeUndefined(); // it fail
	});
});
@Pmyl
Copy link
Collaborator

Pmyl commented Jan 21, 2019

Tell me if I'm wrong, to solve this at some extent we just need to normalize the variable names to avoid [Symbol.toStringTag] to error as a name. The fact is that normally a Promise is not mocked entirely so probably it shouldn't happen here too.

This issue actually brings up a problem with intersection types when one part of the intersection is a function. That is going to either fail miserably in the same way as the Promise case or is just going to mock entirely the Function without using the MockFactory (jasmine, jest, etc).

Maybe we need to review how we handle intersection types?

@uittorio
Copy link
Member Author

Yes, so the problem is how we are handling intersection types. Right now is using getPropertyOfTypes from typescript api, and that functionality try to fetch all the properties of a real Promise. We definitely have to solve Symbol.toStringTag and I have to make sure that the type is converted to our Promise before converting it. Unfortunately the conversion of the Promise is not centralised yet

@Pmyl
Copy link
Collaborator

Pmyl commented Dec 30, 2019

@uittorio I think this is already working. The behaviour is that if something comes from typescript types it ignores it completely.

Let me know if this can be closed

@uittorio
Copy link
Member Author

We can ignore this issue with the assumption that we ignore typescript libs for intersections. If we are happy with that we can close it for now. If in the future we need the functionality we can open a new issue

@Pmyl Pmyl closed this as completed Dec 30, 2019
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