Kimmo Hintikka Kimmo Hintikka - 3 months ago 42
React JSX Question

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.

Answer

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

QUICK:

typings install dt~react --save --global.

Similar for react-dom.

Comments