google/intermock

Types from tsconfig are not available in node api

KevinMind opened this issue · 1 comments

Given:

types.ts

interface Test {
  promise: Promise<any>;
}

tsconfig.json

{
  "compilerOptions": {
    "lib": [
      "es2015",    ],
}

and my usage file test.ts

const data = mock({
  files: [
    [
      path.join(__dirname, 'types.ts'),
      fs.readFileSync(path.join(__dirname, 'types.ts'), 'utf-8')
    ],
  ],
  interfaces: ['Test'],
  output: 'object',
});

I would expect the following interface to work, but I get the error:

Type 'Promise' is not specified in the provided files but is required for property: 'promise'. Please include it.

In the docs we see that 'Interfaces with property references to other complex types ' are supported. since Promise is an other complex types I would assume it would work.

Is there some special configuration for including a tsconfig or do we need to import all type dependencies? or how should we handle such cases. We are currently investigating using this lib for mocking in test and dev environments and will need to support many such use cases such as dom types, react component types, etc.

Please advise :)

Bump! I'm having a similar issue with the builtin TypeScript Record type.

Using this interface:

interface Test {
  record: Record<string, string>;
}

I get the following error message:
Type 'Record' is not specified in the provided files but is required for property: 'record'. Please include it.

How should we handle these cases with builtin TypeScript types? If they are not currently supported, we can expect some support in the near future?

Any help/clarification is appreciated!