Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript errors (TS2416) when compiling an app in strict mode due to mismatch in interface implementations #504

Open
StefanNedelchev opened this issue Mar 22, 2023 · 7 comments

Comments

@StefanNedelchev
Copy link
Contributor

StefanNedelchev commented Mar 22, 2023

I have imported @cornerstonejs/core in an Angular app which uses strict mode in tsconfig and I implemented a simple code that should load a single image in a viewport. The build fails due to some TypeScript errors in the cornerstone type definitions:

image

The screenshot includes only part of the errors but the others suffer from similar symptoms - some methods inside class declarations don't exactly match (in terms of return type and argument types) the methods from the interfaces they implement.

An example with StackViewport where the return type of getFrameOfReferenceUID() includes undefined but in the interface IStackViewport and IViewport the return type is strictly a string. Also I'm not sure why IStackViewport duplicates so many things from IViewport given the fact it already extends IViewport. The latter can actually be noticed in other interfaces as well (if needed I'll create a separate issue for this).
image

@sedghi
Copy link
Member

sedghi commented Mar 23, 2023

This is a great find indeed, do you want to create a PR? I can help you to merge it

@StefanNedelchev
Copy link
Contributor Author

StefanNedelchev commented Mar 24, 2023

@sedghi Thanks, I might try to create PRs for each of the issues I've raised. Although keep in mind that fixing all strict type check issues might be tricky as the current TS config has strictNullChecks set to false (which is the main reason for why all these errors were allowed to happen) and removing it opens up 657 TS errors across 64 files that need to be carefully reviewed.

@sedghi
Copy link
Member

sedghi commented Mar 24, 2023

I will try to create a branch that experiment with fixing those 657 errors

bionoone pushed a commit to bionoone/cornerstone3D-beta that referenced this issue Mar 27, 2023
Looks good to me - simply change to allow skipping the image creation.
@VijayanRamachandran
Copy link

Hi @sedghi @StefanNedelchev ,

i am also facing same issue in Angular when i use latest version of Cornerstone3D

image

Any suggestion about temporary workaround to solve it or already any permanent fix to it which you could share please ?

Regards,
Vijayan Ramachandran

@StefanNedelchev
Copy link
Contributor Author

StefanNedelchev commented Sep 26, 2023

Hi @sedghi @StefanNedelchev ,

i am also facing same issue in Angular when i use latest version of Cornerstone3D

image

Any suggestion about temporary workaround to solve it or already any permanent fix to it which you could share please ?

Regards, Vijayan Ramachandran

Hi. Unfortunately I decided to give up trying until Cornerstone3D officially goes in strict TS mode (which is difficult to prioritize when they focus on bug fixing and features). As for a temporary solution, unfortunately I'm not aware of other way than setting the strict option to false in your tsconfig. The downside is that it would disable it entirely in the project but I think it's impossible to tweak the config in a way to ignore strict type checking for node_modules. Also I think using @ts-ignore on the imports is no longer supported by TS

@sedghi
Copy link
Member

sedghi commented Sep 26, 2023

Yeah as Stefan mentioned, unfortunately it is not a priority at the moment, although I'm more than happy to review a PR if someone is trying to fix our types

@VijayanRamachandran
Copy link

Hi @sedghi @StefanNedelchev ,

Thanks for the quick response..

for now i am proceeding with below configurations in tsconfig.json

"types": ["node"],
"noImplicitAny": false,
"strictNullChecks":false,
"skipLibCheck": true,

Regards,
Vijayan Ramachandran

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants