Kimmo Hintikka
Kimmo Hintikka

Reputation: 15530

React typescript import syntax issues with vscode

I just started testing with react typescript + Meteor and I cannot figure out how to setup VSCode properly.

TSX and TS file react autocomplete and syntax highlighting works fine, but every module import trickers vscode critical errors.

[ts] Cannot find module 'react'
[ts] Cannot find module 'react-dom'

My import statement below.

import * as React from "react";
import { render } from "react-dom";

Components load fine so imports actually are working, but I get syntax highlighting issues for every import and I want to fix this.

I do not have any tsconfig.json files or typings folder.

I am using https://github.com/barbatus/typescript to automatically transpile typescript files for meteor build. Background this has both typings files tsconfig.json.

Upvotes: 2

Views: 2442

Answers (3)

basarat
basarat

Reputation: 276383

you need to get typings for react and react-dom.

QUICK:

npm install --save-dev @types/react @types/react-dom.

Similar for react-dom.

Upvotes: 4

Kalle
Kalle

Reputation: 3907

instead of typings use npm directly.

npm install --save-dev @types/react @types/react-dom

Upvotes: 2

Dimpu Aravind Buddha
Dimpu Aravind Buddha

Reputation: 9845

Make sure you have tsconfig file.

Upvotes: 0

Related Questions