typescript编译Decorators时报错

typescript编译Decorators时报错:Unable to resolve signature of method decorator when called as an expression.
解决

1.配置tsconfig.json ---官网推荐(我自己并未解决)

"compilerOptions": {
      "target": "ES5",
      "experimentalDecorators": true
  }

2.命令行

tsc --target ES5 --experimentalDecorators

3.类型定义解决---

创建一个变量接受connect,虽然解决了这个问题,但是重新赋值,并不太推荐

const connect1: any = connect;
@connect1(
  ({ counter }) => ({
    counter
  }),
  dispatch => ({
    add() {
      dispatch(add());
    },
    minus() {
      dispatch(minus());
    }
  })
)

你可能感兴趣的:(typescript编译Decorators时报错)