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

Types from tsconfig are not available in node api #55

Open
KevinMind opened this issue Apr 30, 2021 · 1 comment
Open

Types from tsconfig are not available in node api #55

KevinMind opened this issue Apr 30, 2021 · 1 comment

Comments

@KevinMind
Copy link

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 :)

@DavidCChi
Copy link

DavidCChi commented Sep 29, 2021

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!

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