【发布时间】:2018-02-01 07:15:03
【问题描述】:
在我的一个项目中,我收到以下错误消息:
test/node_modules/@types/leaflet/index.d.ts(856,11): error TS2415: Class 'GeoJSON' incorrectly extends base class 'FeatureGroup'.
Types of property 'setStyle' are incompatible.
Type '(style: StyleFunction) => this' is not assignable to type '(style: PathOptions) => this'.
Types of parameters 'style' and 'style' are incompatible.
Type 'PathOptions' is not assignable to type 'StyleFunction'.
Type 'PathOptions' provides no match for the signature '(feature?: Feature<GeometryObject>): PathOptions'.
这里是输入文件:
test.ts
import { LatLngExpression } from 'leaflet'
package.json
{
"name": "test",
"version": "0.0.1",
"description": "",
"author": "",
"license": "ISC",
"devDependencies": {
"@types/leaflet": "^1.0.68",
"gulp": "^3.9.1",
"gulp-typescript": "^3.2.2",
"typescript": "^2.4.2"
}
}
tsconfig.json
{
"compileOnSave": true,
"compilerOptions": {
"noEmitOnError": true,
"target": "es5",
"module": "amd",
"moduleResolution": "node"
},
"include": [
"test.ts"
]
}
gulpfile.js
const gulp = require('gulp');
const ts = require("gulp-typescript");
const tsProject = ts.createProject("tsconfig.json");
gulp.task('default', () => {
const tsResult = tsProject.src().pipe(tsProject());
return tsResult.js.pipe(gulp.dest(''));
});
如果我执行“yarn && gulp”,则会出现错误——但如果我使用“npm install”而不是yarn,则不会出现错误,如果我使用“tsc -p”则不会。而不是 gulp 文件。 此外,只要我有 Typescript 2.4.1,就完全没有错误——它是在我更新到 Typescript 2.4.2 之后出现的。
我想将此报告为错误 - 但我不知道是哪个部分负责:yarn、typescript、gulp-typescript、@types/leaflet?
我怎么能弄到这个?
显然,我从一个较大的项目中提取了这个测试用例,我想在其中使用“yarn && gulp”,这会导致错误。所以我想要修复 - 不是上面的任何“解决方法”。
【问题讨论】:
标签: typescript npm leaflet yarnpkg gulp-typescript