Tim*_*mes 5 resharper momentjs typescript reactjs
我正在使用React + TypeScript + NPM进行包管理,然后使用Webpack进行编译和捆绑.
我正在使用时间进行日期转换和本地化,我使用以下代码处理所有内容;
import * as React from 'react';
import * as moment from 'moment';
class DateFilter extends React.Component<{ value: Date }, {}>{
render(){
const { value } = this.props;
return (
<time>{ moment(value).format('YYYY-MM-DD') }</time>
);
}
}
Run Code Online (Sandbox Code Playgroud)
所有工作都按预期工作,但是当Resharper打开时,它会给我一个错误: Cannot invoke an expression whose type lacks a call signature
我已经浏览了各种博文/问题,并且都建议这是导入时刻的正确方法.
我的package.json包含......
"dependencies": {
"moment": "^2.18.1",
"moment-timezone": "^0.5.13",
},
"devDependencies": {
"@types/moment": "^2.13.0",
"@types/moment-timezone": "^0.2.34",
}
Run Code Online (Sandbox Code Playgroud)
我的tsconfig.json看起来像;
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": "Scripts",
"module": "es2015",
"moduleResolution": "node",
"target": "es5",
"jsx": "react",
"experimentalDecorators": true,
"outDir": "./wwwroot/scripts",
"removeComments": false,
"sourceMap": true,
"skipDefaultLibCheck": true,
"strict": false,
"lib": [ "es6", "dom" ],
"noImplicitAny": false,
"paths": {
"App/*": [ "App/*" ],
"Utility/*": [ "Utility/*" ]
}
},
"exclude": [
"bin",
"node_modules",
"wwwroot"
]
}
Run Code Online (Sandbox Code Playgroud)
如果我运行webpack,那么一切正常,没有错误.瞬间正常运作,但只是Resharper吓坏了.
| 归档时间: |
|
| 查看次数: |
332 次 |
| 最近记录: |