Skip to content

Typescript does not import JSON and throws Type error  #5613

Closed

Description

@MattyBalaam

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

JSON, import JSON

Environment

System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 10.11.0 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Browsers:
Chrome: 70.0.3538.77
Firefox: 63.0
Safari: 12.0
npmPackages:
react: Not Found
react-dom: Not Found
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found

Steps to Reproduce

  1. add a json file to project
  2. add import json from './test.json'; to another file
  3. start compilation

Expected Behavior

Json file is imported into app and become JS object - which works in a refular .js CRA project.

Actual Behavior

Type error: Cannot compile namespaces when the '--isolatedModules' flag is provided. TS1208

screen shot 2018-10-29 at 10 19 06

Reproducible Demo

https://github.com/MattyBalaam/json-typescript-CRA-bug-report

  1. install dependencies
  2. run start

Activity

  1. Timer commented on Oct 29, 2018

    @Timer
    Contributor
  2. added this to the 2.1 milestone on Oct 29, 2018
  3. added a commit that references this issue on Oct 29, 2018
    41364e4
  4. added a commit that references this issue on Oct 29, 2018
    feea693
  5. added a commit that references this issue on Oct 29, 2018
    54c107d
  6. added a commit that references this issue on Oct 30, 2018
    cde4e88
  7. locked and limited conversation to collaborators on Jan 9, 2019
  8. added a commit that references this issue on Feb 24, 2019
    e220a5f
  9. added a commit that references this issue on Mar 2, 2019
    04eedd2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions