TypeScript
Code
Framer X

Fix editor error when importing a local JSON file

HT @marciplan.

In our code components or code overrides, we can import a json file like so:

import * as rows from './rows.json'

This works, but we’ll get an error in the editor:

import error

To fix it:

  1. open the Project Folder
  2. open the tsconfig.json file
  3. add the highlighted line below and restart Visual Studio Code:
{
  "compilerOptions": {
    "target": "es2015",
    "lib": ["es2015", "dom"],
    "module": "commonjs",
    "jsx": "react",
    "outDir": "build",
    "resolveJsonModule": true,
    "sourceMap": false,
    "declaration": false
  },
  "exclude": ["node_modules", "build"]
}

PS: If you find this tip difficult to understand, check out this course I prepared for you, where concepts are explained in a more digestible way. No programming experience required!

PPS: See other pro tips, or share / request a new tip.


download Want the complete source file? Enter your email address below:

I'll also send you new tips when available. No spam, unsubscribe any time!


© 2018 jimu Labs, Inc.