Skip to content

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

Closed
@ianobermiller

Description

@ianobermiller

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions