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

add support for default generics on declaration and extensions #126

Merged
merged 4 commits into from
Dec 31, 2019

Conversation

uittorio
Copy link
Member

No description provided.

@uittorio
Copy link
Member Author

uittorio commented Dec 30, 2019

Now we are using the type(generics)declarations instead of the typeArguments to loop through the generics

interface Interface<A> { // A is the typeDeclaration
 prop: A;
}
createMock<Interface<string>>(); // string is the typeArgument

with the typeDeclaration its easier to store default generics if not provided

Example

interface InterfaceB<T> {
 bProp: T;
}
interface InterfaceA<A = string> extends B { 
 prop: A;
}

createMock<InterfaceA>();

When we check interface B we didn't really store the default value in A so it was not possible to auto default to string.

The code now is checking against typeDeclaration and if the generic has been provided in typeArguments. If not it will store the default generic.

I hope it make sense

Pmyl
Pmyl previously approved these changes Dec 30, 2019
# Conflicts:
#	src/transformer/mockFactoryCall/mockFactoryCall.ts
@uittorio uittorio merged commit a9df32a into master Dec 31, 2019
uittorio added a commit that referenced this pull request Jan 4, 2020
… and extensions (#126)

* add support for default generics on declaration and extensions

* reduce amount of nested if statements

* reduce amount of if statement in generic extensions
@uittorio uittorio deleted the feature/default-generics branch January 5, 2020 14:21
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

Successfully merging this pull request may close these issues.

2 participants