Skip to content

Generics defaulting doesn't work #617

Open
@wassy92x

Description

@wassy92x

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions