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

Typescript compilation fails because "files" property in tsconfig.json appears to be ignored #5790

Closed
ericbiewener opened this issue Dec 9, 2020 · 6 comments
Labels
STATE: Need clarification An issue lacks information for further research.

Comments

@ericbiewener
Copy link

What is your Test Scenario?

I enable importing *.graphql files as strings in my app via webpack's raw-loader, and tell TS to consider these imports to be strings via a declaration file:

assets.d.ts

declare module "*.graphql" {
  const content: string;
  export default content;
}

I then tell the TS compiler about this declaration file via the files property in tsconfig.json:

tsconfig.json

{
  ...
  "files": ["./types/assets.d.ts"]
}

Finally, I provide the path to this tsconfig.json via runner.tsConfigPath(tsConfigPath).

What is the Current behavior?

Testcafe fails to compile the TypeScript test:

/Users/eric/my-repo/libs/account/data-access/src/__mock-api__/schema.ts (1, 38): Cannot find module '../schema.graphql' or its corresponding type declarations.

    at Function._reportErrors (/Users/eric/my-repo/node_modules/testcafe/lib/compiler/test-file/formats/typescript/compiler.js:41:15)
    at TypeScriptTestFileCompiler._compileFilesToCache (/Users/eric/my-repo/node_modules/testcafe/lib/compiler/test-file/formats/typescript/compiler.js:58:40)
    at TypeScriptTestFileCompiler._precompileCode (/Users/eric/my-repo/node_modules/testcafe/lib/compiler/test-file/formats/typescript/compiler.js:79:18)
    at TypeScriptTestFileCompiler._compileCodeForTestFiles (/Users/eric/my-repo/node_modules/testcafe/lib/compiler/test-file/api-based.js:86:29)
    at /Users/eric/my-repo/node_modules/testcafe/lib/compiler/test-file/formats/typescript/compiler.js:46:26
    at Compiler._precompileFiles (/Users/eric/my-repo/node_modules/testcafe/lib/compiler/index.js:47:33)
    at Function.all (<anonymous>:null:null)
    at Compiler._compileTestFiles (/Users/eric/my-repo/node_modules/testcafe/lib/compiler/index.js:72:9)
    at Compiler.getTests (/Users/eric/my-repo/node_modules/testcafe/lib/compiler/index.js:84:34)
    at LiveModeBootstrapper._getTests (/Users/eric/my-repo/node_modules/testcafe/lib/runner/bootstrapper.js:129:21)
    at Function.all (<anonymous>:null:null)
    at LiveModeBootstrapper._bootstrapParallel (/Users/eric/my-repo/node_modules/testcafe/lib/runner/bootstrapper.js:226:38)
    at LiveModeBootstrapper.createRunnableConfiguration (/Users/eric/my-repo/node_modules/testcafe/lib/runner/bootstrapper.js:254:69)

What is the Expected behavior?

TS compiles without error

Your Environment details:

  • testcafe version: 1.9.4
  • node.js version: 14.11.0
  • command-line arguments: Let me know if there is a way to output this. I'm running the tests via a JS script that uses createTestCafe
  • browser name and version: N/A
  • platform and version: N/A
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 9, 2020
@SergeyShurygin
Copy link

Hi,

In the upcoming 1.10.0 version, we plan to release the Custom Compiler Options feature, which should allow you to implement your scenario. Here is corresponding issue and PR. Once the 1.10.0 version is released, can you check if it solves the issue? Otherwise, we would appreciate if you send us a working example reproducing the problem.

@SergeyShurygin SergeyShurygin added the STATE: Need clarification An issue lacks information for further research. label Dec 10, 2020
@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 10, 2020
@ericbiewener
Copy link
Author

Are you sure that will fix it? My concern is that the files property in tsconfig.json is not part of the compilerOptions object property -- it's a top-level property. Perhaps your naming the feature "compiler options" doesn't mean that it is only going to consider the compilerOptions property in tsconfig, but the naming makes me nervous :)

@no-response no-response bot removed the STATE: Need clarification An issue lacks information for further research. label Dec 11, 2020
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 11, 2020
@SergeyShurygin
Copy link

Yes, the "Compiler Options" is the name of the CLI parameter and the runner method: https://devexpress.github.io/testcafe/documentation/guides/concepts/typescript-and-coffeescript.html#customize-compiler-options
You can try it with the latest 1.10.0 RC version, (1.10.0-rc.7) available on npm.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 14, 2020
@SergeyShurygin SergeyShurygin added the STATE: Need clarification An issue lacks information for further research. label Dec 14, 2020
@thansber
Copy link

Will this Compiler Options feature handle custom "paths" mappings in tsconfig.json files as well? Specifically will it address #4144?

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 15, 2020
@miherlosev
Copy link
Contributor

Hi @thansber

No. The 'Compiler Options' feature will not handle custom path mappings. You can use any workaround from the #4144 issue.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 16, 2020
@no-response
Copy link

no-response bot commented Dec 24, 2020

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

@no-response no-response bot closed this as completed Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATE: Need clarification An issue lacks information for further research.
Projects
None yet
Development

No branches or pull requests

4 participants