2

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.

1
  • Do you have react.d.ts and react-dom.d.ts in your project? Commented Jun 30, 2016 at 0:02

3 Answers 3

4

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

QUICK:

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

Similar for react-dom.

Sign up to request clarification or add additional context in comments.

1 Comment

I accepted the answer as it must be right one. For some reason importing react will still give issues and I actually already had react typings globally installed, but once I installed react-dom typings that error went away. Next I try to reinstall my react typings and update typings package itself.
2

instead of typings use npm directly.

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

Comments

0

Make sure you have tsconfig file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.