Skip to content

Typescript does not import JSON and throws Type error  #5613

Closed
@MattyBalaam

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions