dicomParser icon indicating copy to clipboard operation
dicomParser copied to clipboard

dicomParser.ByteStream not found

Open jdbogdan opened this issue 3 years ago • 1 comments

jdbogdan avatar Sep 30 '21 07:09 jdbogdan

Thanks for the report, but it's a little hard to track down what's going on here with so little information. Is there anything else you can provide? Where are you getting this error? How are you trying to access ByteStream? Is this TypeScript? Browser or Node, etc.?

yagni avatar Oct 01 '21 14:10 yagni

Hello, I am joining this question by providing some additional specifications. I use Typescript and I need to create a ByteStream object in my code, but when I try to create it, I get the error "The property 'ByteStream' does not exist in the type 'typeof import (" dicom-parser ")' ".

import * as DicomParser from 'dicom-parser';

export async function TestRead(byteArray: Uint8Array): Promise<void> {
    let byteStream = new DicomParser.ByteStream(DicomParser.littleEndianByteArrayParser, byteArray);
    // some code...
}

Enrico-A avatar Aug 30 '22 14:08 Enrico-A

Seems ByteStream exists in the index.d.ts but I have a slightly different but related problem:

https://codesandbox.io/s/typescript-forked-ei38tw?file=/src/index.ts

TypeScript complains if you try to construct one since it's exported as an interface instead of a class from index.d.ts. This works at runtime, so it's a matter of aligning typings.

kmannislands avatar Sep 14 '22 20:09 kmannislands

I think I've solved my problem, and it might solve your code problem as well. I modified the code in this way and was able to create the ByteStream object:

import * as Dicomparser from "dicom-parser";

export async function TestRead(byteArray: Uint8Array): Promise<void>  {
    const byteStream: Dicomparser.ByteStream = new Dicomparser.ByteStream(
        Dicomparser.littleEndianByteArrayParser, 
        byteArray, 
        0);
}

Enrico-A avatar Sep 15 '22 15:09 Enrico-A

:tada: This issue has been resolved in version 1.8.15 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

ohif-bot avatar Sep 19 '22 13:09 ohif-bot