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

yarn test adds isolatedModules to tsconfig, conflicts with declaration option #6551

Closed
ianobermiller opened this issue Mar 1, 2019 · 3 comments
Labels

Comments

@ianobermiller
Copy link

According to this comment, in order to compile TypeScript with Babel, you need the isolatedModules flag. However, this flag is incompatible with the declaration flag, which is used to avoid manually duplicated TypeScript type definitions for a library. We have been compiling redux-react-hook just fine without isolatedModules, but every time we run yarn test it is added back in and needs to be reverted. Is there a way for emitted declaration files to play nicely with create-react-app?

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

➜ yarn --version
1.12.3

Which terms did you search for in User Guide?

typescript, tsconfig, declaration, isolatedModules

Environment

➜ create-react-app --info

Environment Info:

System:
OS: macOS 10.14.1
CPU: x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Binaries:
Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
Yarn: 1.12.3 - ~/.yarn/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm
Browsers:
Chrome: 72.0.3626.119
Safari: 12.0.1
npmPackages:
react: ^16.8.3 => 16.8.3
react-dom: ^16.8.3 => 16.8.3
react-scripts: ^2.1.3 => 2.1.3
npmGlobalPackages:
create-react-app: Not Found

Steps to Reproduce

  1. yarn create react-app cra-tsconfig-bug --typescript
  2. cd cra-tsconfig-bug
  3. touch .watchmanconfig
  4. In tsconfig.json, change isolatedModules to declaration
  5. Run yarn test
  6. Note that isolatedModules: true is added back to tsconfig.json
  7. Run the typescript compiler (open a tsx file in VSCode for example)
  8. See the error: "Option 'declaration' cannot be specified with option 'isolatedModules'"

Expected Behavior

yarn test should not be modifying my tsconfig.json to put it in an invalid state

Actual Behavior

yarn test adds isolatedModules: true, which is not compatible with declaration: true for emitting declaration files.

Reproducible Demo

See steps above, this is very easy to reproduce.

@stale
Copy link

stale bot commented Mar 31, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Mar 31, 2019
@stale
Copy link

stale bot commented Apr 5, 2019

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Apr 5, 2019
@ianobermiller
Copy link
Author

I assume this isn't getting any traction because when you use babel to compile typescript, as create-react-app does, you are supposed to use isolatedModules, and isolatedModules is not compatible with declaration, per microsoft/TypeScript#29490.

@lock lock bot locked and limited conversation to collaborators Apr 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant