`import {Component}来自'react'`而不是`import * as React ..` in typescript

时间:2017-10-28 22:29:38

标签: reactjs typescript webpack ts-loader

抱歉超级新手含糊不清的问题,但我可以吗

import {Component} from 'react'

class MyComponent extends Component { ..

而不是

import * as React from 'react` 

class MyComponent extends React.Component { ..

在babel / webpack / typescript / react ish environment?

如果没有,为什么?

我的webpack.config.json看起来像这样。

module: {
  rules: [
    {
      test: /\.js$/,
      use: ['babel-loader', 'source-map-loader'],
      exclude: /node_modules/
    },
    {
      test: /\.tsx?$/,
      exclude: /node_modules/,
      loader: 'happypack/loader?id=ts'
    },

...

plugins: [
  new HappyPack({
    id: 'ts',
    threads: 2,
    loaders: [
      {
        path: 'ts-loader',
        query: { happyPackMode: true }
      }
    ]
  }),

...

0 个答案:

没有答案