2017-08-23 40 views
1

在我的项目,我收到此错误信息:类 'GeoJSON的' 不正确扩展基类FeatureGroup“

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('')); 
}); 

如果我执行 “纱& &吞掉” 出现错误 - 但不是,如果我使用 “故宫安装”,而不是纱,而不是如果我使用“tsc -p”。而不是吞噬文件。 此外,只要我有Typescript 2.4.1,根本没有错误 - 它在我更新到Typescript 2.4.2后出现。

我想报告这是一个错误 - 但我不知道哪个部分是负责任的:纱线,打字稿,吞食打字稿,@ types/leaflet?

我怎么能得到这个?

很明显,我从一个更大的项目中提取了这个测试用例,我想用“yarn & & gulp”,这会导致错误。所以我想要修正 - 而不是上面的任何“解决方法”。

回答

0

由于它似乎已被“自动地”修复。我的猜测是,npm和纱线存储库之间存在不一致。

很难说 - 也许没用。所以这个问题可能会被关闭或删除。

+0

我确实有同样的问题,所以我想这个问题应该留下来。 – Tx3

0

在将Typescript从2.4版升级到2.5版后,我也遇到过类似的问题。更新@ types/leaflet模块解决了我的问题。

npm update @types/leaflet