此错误通常意味着尝试将使用不受支持的类型传递给 GeoJSON 对象。要解决此错误,请确保通过正确的类型传递 GeoJSON 对象。以下是一个示例:
正确的类型:
import { FeatureCollection } from 'geojson';
const myFeatureCollection: FeatureCollection = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {
name: 'Some Name',
},
geometry: {
type: 'Point',
coordinates: [0, 0],
},
},
],
};
错误的类型:
const myFeatureCollection = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {
name: 'Some Name',
},
geometry: {
type: 'Point',
coordinates: [0, 0],
},
},
],
};
上一篇:Argumentoftype'unknown'isnotassignabletoparameteroftype'string'.TS2345
下一篇:Argumentoftypeisnotassignabletoparameteroftypeerrorisincludingprivatefields