Argument of type 'string | ArrayBuffer | Blob | number[] | Uint8Array | Buffer | ReadableStream' is not assignable to parameter of type 'Blob | MediaSource'.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 321
- Forks
- 195
- PR merge metrics
- No merged PRs in 30d
Description
I keep getting this typescript issue here below on this line `const url = URL.createObjectURL(blob);`
> Argument of type 'string | ArrayBuffer | Blob | number[] | Uint8Array | Buffer | ReadableStream' is not assignable to parameter of type 'Blob | MediaSource'.
Type 'string' is not assignable to type 'Blob | MediaSource'.ts(2345)
const blob: string | Blob | number[] | Uint8Array | ArrayBuffer | Buffer | ReadableStream
```
const convertToShapefileAndDownload = async (geoJson) => {
try {
if (!geoJson || typeof geoJson !== 'object') {
throw new Error('Invalid GeoJSON data');
}
const options: any = {
folder: 'plots',
types: {
point: 'points',
polygon: 'polygons',
polyline: 'lines',
},
compression: 'STORE' as any,
outputType: 'blob',
};
const blob = await shpwrite.zip(geoJson, options);
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'plots_shapefile.zip';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
} catch (error) {
//handleNotification(error, 'error');
console.error('Error converting to Shapefile:', error.message);
}
};
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the shpwrite.zip entry point and inspect the type declaration or implementation for its outputType option. Reproduce the TypeScript error with outputType: 'blob', then verify the package's reported return type matches the value produced and that the example can pass it to URL.createObjectURL without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100