Skip to content

Instantly share code, notes, and snippets.

@hrgui
Last active April 14, 2017 04:15
Show Gist options
  • Save hrgui/1fc7bb5c23d4ecead3b7383102c869e4 to your computer and use it in GitHub Desktop.
Save hrgui/1fc7bb5c23d4ecead3b7383102c869e4 to your computer and use it in GitHub Desktop.
JSX to TSX

So you want to do TSX?

instructions

install "@types/node": "^7.0.12",

modify webpack.config.dev.js

{
        test: /\.(ts|tsx)$/,
        loader: 'tslint',
        include: paths.appSrc,
      }
      
      


    // Process JS with Babel.
      {
        test: /\.(ts|tsx)$/,
        include: paths.appSrc,
        loader: 'ts'
      },
      
      

modify appIndexJs in paths.js

 
        appIndexJs: resolveApp('src/index.tsx'),

ts-loader

Protips

  1. Migrate slowly, don't import the Root of your app ASAP
  2. Migrate files that don't have alot of dependencies (your view components first)

Errors encountered

Uncaught (in promise) TypeError: Cannot read property 'createElement' of undefined
Check the render method of * (this is due to a component not being imported correctly)

Solution

import * as React from 'react';

Invalid object blabla

import * as PropTypes from 'prop-types';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment