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

ts-ignore on import in selection-types.ts #544

Closed
wants to merge 3 commits into from

Conversation

jordanhboxer
Copy link

@jordanhboxer jordanhboxer commented Oct 2, 2024

This needs to be added otherwise I have to disable noImplicitAny in my tsconfig.json which can hide other errors.
This wouldn't be needed either if the file were a compiled declaration file (.d.ts) because of skipLibCheck in the tsconfig.json so this seems like the simplest solution

This needs to be added otherwise I have to disable `noImplicitAny` in my tsconfig.json which can hide other errors
build step failed with @ts-expect-error
@jordanhboxer jordanhboxer changed the title ts-expect-error on import in selection-types.ts ts-ignore on import in selection-types.ts Oct 2, 2024
@kwonoh
Copy link
Contributor

kwonoh commented Oct 2, 2024

I get the below error from a typescript project with "noImplicitAny": true while this repo has "noImplicitAny": false.

[TypeScript] Could not find a declaration file for module '../MosaicClient.js'. '<path>/@uwdata/mosaic-core/src/MosaicClient.js' implicitly has an 'any' type.
<path>/@uwdata/mosaic-core/src/util/selection-types.ts:2:30
    1 | import { SQLExpression } from '@uwdata/mosaic-sql';
  > 2 | import { MosaicClient } from '../MosaicClient.js';
      |                              ^^^^^^^^^^^^^^^^^^^^
    3 |
    4 | /**
    5 |  * Selection clause metadata to guide possible query optimizations.

Adding // @ts-ignore resolve the above issue.

However, if selection-types.ts will only contain type definitions, I think it should be named as selection-types.d.ts so the library users can use skipLibCheck for addressing this kind of issue.

@domoritz domoritz self-requested a review October 2, 2024 19:36
Copy link
Member

@domoritz domoritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you enable skipLibCheck in your config? Wouldn't that ignore type errors in the library?

If we want to make a change here, I would suggest that we enable noImplicitAny to check everything and avoid potential regressions and instead of ts-ignore, should we add the missing declarations?

@kwonoh
Copy link
Contributor

kwonoh commented Oct 2, 2024

skipLibCheck only skips *.d.ts files but selection-types.ts is a *.ts file not a *.d.ts file. so skipLibCheck doesn't skip selection-types.ts

We weren't sure about the scope of selection-types.ts whether it will only contain type definitions or actual functioning code. If it will only contain type definitions, selection-types.ts should be renamed to selection-types.d.ts.

I think changing "noImplicitAny": false to "noImplicitAny": true is a big change for mosaic that will essentially require actual typescript support from mosaic.

@domoritz
Copy link
Member

domoritz commented Oct 2, 2024

I see. I'm okay with moving to .d.ts files for everything but iirc there was some reason @jheer used ts files.

Id love to have a setup that lets is gradually transition to ts. If you could make a proposal that would be awesome.

Happy to merge this pull request if it's a stopgap but you would probably need a release, no?

@kwonoh
Copy link
Contributor

kwonoh commented Oct 2, 2024

Yes, we would need a release. But we can wait for @jheer's response on whether changing selection-types.ts to selection-types.d.ts will work.

@domoritz
Copy link
Member

domoritz commented Oct 2, 2024

If you can, go ahead and try.

@kwonoh
Copy link
Contributor

kwonoh commented Oct 2, 2024

Id love to have a setup that lets is gradually transition to ts. If you could make a proposal that would be awesome.

Yes, we'd like to contribute TS support. Is there a plan on a direction for TS support? like adding type definitions (*.d.ts files) along with the current JS code OR porting the current JS code to TS?

Let's see if this works
@kwonoh
Copy link
Contributor

kwonoh commented Oct 2, 2024

Changing selection-types.ts to selection-types.d.ts seems to work locally. I didn't see any errors from build/lint/test/docs:build. Waiting for the repo's workflow to kick in.

@domoritz
Copy link
Member

domoritz commented Oct 2, 2024

Support supportive of going ts but we want to make sure it's done in a way where we don't need to re-compile a sub-project to get the updates in another. Ideally, we figure out some way to do gradual transitions, that would be best and then send follow up PRs to change individual models.

Related: #312

@jheer
Copy link
Member

jheer commented Oct 2, 2024

I need to understand the issue better. Right now the setup is to primarily use JavaScript (.js), alongside TypeScript (.ts) files to more conveniently define types.

I think what's missing (relative to what I've done in other projects like Arquero and Flechette), is then use both of these as input to tsc as part of the build process to produce "official" types as .d.ts files that are linked from the types property in package.json.

So why don't we do that instead, and see if it resolves import issues?

@jordanhboxer
Copy link
Author

@jheer That sounds like the ideal solution given that that will produce the correct output in the built package rather than using a declaration file in the source code.

To give you some more context, our build pipeline runs tsc on all .ts files and since it hasn't been compiled to a declaration file we can't ignore it skipLibCheck. Setting "noImplicitAny": false is not ideal for us either as that will hide potential issues.

@domoritz
Copy link
Member

domoritz commented Oct 2, 2024

Like this #545?

@jordanhboxer
Copy link
Author

I believe so!

@domoritz
Copy link
Member

domoritz commented Oct 3, 2024

Should be fixed by #545.

@domoritz domoritz closed this Oct 3, 2024
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

Successfully merging this pull request may close these issues.

4 participants