cornerstonejs / cornerstone3D

Cornerstone is a set of JavaScript libraries that can be used to build web-based medical imaging applications. It provides a framework to build radiology applications such as the OHIF Viewer.
https://cornerstonejs.org
MIT License
548 stars 283 forks source link

[Bug] @cornerstonejs/tools/dist/types/utilities/getViewportForAnnotation.d.ts:2:141 - error TS2307: Cannot find module 'packages/core/dist/types/types' or its corresponding type declarations. #1203

Open robertlario opened 5 months ago

robertlario commented 5 months ago

Describe the Bug

File getViewportsForAnnotation.d: import type { Annotation } from '../types'; export default function getViewportsForAnnotation(annotation: Annotation): (import("packages/core/dist/types/types").IVolumeViewport | import("packages/core/dist/types/types").IStackViewport)[];

Has "packages/core/dist/types/types".

File getViewportForAnnotation.d.ts : import type { Annotation } from '../types'; export default function getViewportForAnnotation(annotation: Annotation): import("packages/core/dist/types/types").IVolumeViewport | import("packages/core/dist/types/types").IStackViewport;

The directory "packages" does not exist.

Steps to Reproduce

install @cornerstonejs/tools^1.70.5

The current behavior

@cornerstonejs/tools/dist/types/utilities/getViewportForAnnotation.d.ts:2:141 - error TS2307: Cannot find module 'packages/core/dist/types/types' or its corresponding type declarations.

The expected behavior

No build error

OS

Windows 11

Node version

v18.19.0

Browser

N/A

jlopes90 commented 5 months ago

I cannot reproduce the error. Try looking if you've already done it https://www.cornerstonejs.org/docs/getting-started/installation.

robertlario commented 5 months ago

Not sure what to add. I went in directly and changed "packages/core/dist/types/types" to "core/dist/types/types" and it worked fine. I did follow the installation directions as suggested.

This works for me now, so I'll just push forward until I hit this issue again.

simonbertoli commented 5 months ago

Hey all - also getting the same error when updating to the latest tools version

Here is a StackBlitz creating the error https://stackblitz.com/edit/c3d-tools-type-error?file=index.ts

The issue is in this file /@cornerstonejs/tools/dist/types/utilities/getViewportForAnnotation.d.ts

Its referring to an internal package (packages/core/dist/types/types) rather than the cornerstonejs package

The fix is to change the import(s) from packages/core/dist/types/types to @cornerstonejs/core/dist/types/types

frolic06 commented 5 months ago

I get the same error. As a temporary fix, I modified the tsconfig.json: I added this line: "packages/core/dist/types/types": ["node_modules/@cornerstonejs/core/dist/types/types"] in "compilerOptions" / "paths"