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

Generics defaulting doesn't work #617

Open
wassy92x opened this issue Feb 3, 2021 · 1 comment
Open

Generics defaulting doesn't work #617

wassy92x opened this issue Feb 3, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@wassy92x
Copy link
Contributor

wassy92x commented Feb 3, 2021

Subject of the issue

If we like to create an object of an interface with a generic default, the property can't be accessed.
Workaround is possible by using createMock<A<string, string>>

Your environment

  • ts-auto-mock version: 3.1 (master - branch)
  • typescript version: 4.1.3
  • node version: v14.15.1
  • npm version: v14.15.1

Steps to reproduce

For example:

interface A<T, E = T> {
  a: T;
  b: E;
}

const myMock: A<string> = createMock<A<string>>();
console.log(myMock.b);

Expected behavior

'b' should be defined and should be of the first passed type. In the example it should be an empty string

Actual behavior

As soon as I try to access 'b', there is an error: "ReferenceError: t is not defined"

@Pmyl
Copy link
Collaborator

Pmyl commented Feb 3, 2021

Oops, we'll try to figure out why that fails, thanks for opening the issue!

@Pmyl Pmyl added the bug Something isn't working label Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants