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

Typing issues #97

Open
tuner opened this issue May 25, 2023 · 5 comments
Open

Typing issues #97

tuner opened this issue May 25, 2023 · 5 comments

Comments

@tuner
Copy link

tuner commented May 25, 2023

Hi,

I'm trying to validate types (I'm using TS through JSDoc) in my codebase using tsc, but I stumbled upon a couple of issues in @GMOD/bam@1.1.18.

The first one:

../../node_modules/@gmod/bam/dist/util.d.ts:4:44 - error TS2304: Cannot find name 'Long'.

4 export declare function longToNumber(long: Long): number;
                                             ~~~~

There's no "long" package imported in util.d.ts (https://cdn.jsdelivr.net/npm/@gmod/bam@1.1.18/dist/util.d.ts), although it's in the original source file:

import Long from 'long'

🤷

If I checkout v1.1.18 of this repo and compile the project, the long import is missing from util.d.ts. If I checkout HEAD and compile, then it's there. Maybe there's some problem in the old typescript@4.9.4 (?)

And then there's the other issue:

../../node_modules/@gmod/bam/dist/htsget.d.ts:14:5 - error TS2416: Property '_readChunk' in type 'HtsgetFile' is not assignable to the same property in base type 'BamFile'.
  Type '(params: { chunk: { buffer: Buffer; chunk: Chunk; }; opts: BaseOpts; }) => Promise<{ data: Buffer; cpositions: null; dpositions: null; chunk: Chunk; }>' is not assignable to type '({ chunk, opts }: { chunk: Chunk; opts: BaseOpts; }) => Promise<{ data: any; cpositions: any; dpositions: any; chunk: Chunk; }>'.
    Types of parameters 'params' and '__0' are incompatible.
      Type '{ chunk: Chunk; opts: BaseOpts; }' is not assignable to type '{ chunk: { buffer: Buffer; chunk: Chunk; }; opts: BaseOpts; }'.
        Types of property 'chunk' are incompatible.
          Type 'Chunk' is missing the following properties from type '{ buffer: Buffer; chunk: Chunk; }': buffer, chunk

14     _readChunk(params: {
       ~~~~~~~~~~

Indeed, they are different:

async _readChunk({ chunk, opts }: { chunk: Chunk; opts: BaseOpts }) {

async _readChunk({ chunk }: { chunk: Chunk; opts: BaseOpts }) {

However, I don't have enough knowledge of TypeScript to say whether these should be compatible or not. 🤔

And btw, I'm using typescript@5.0.4.

@cmdcolin
Copy link
Collaborator

I recently did some work on typing in #96 as there was indeed a need for some improvements. It may culminate with a major version bump, pretty minor changes to the api but changes nonetheless

I'm not sure about the long thing, sometimes that can imply that I need to include @types/long in the actual dependencies of @gmod/bam instead of just the devDependencies

I would have to assess if there are any remaining type improvements that can be done

@cmdcolin
Copy link
Collaborator

Just curious are you using skipLibCheck:true or false?

@tuner
Copy link
Author

tuner commented May 25, 2023

It's on the default setting (false?). It seems that I can get rid of the error message by setting it to true. Is it a good long-term solution?

@cmdcolin
Copy link
Collaborator

We can likely aim to fix usage of @gmod/bam with skipLibCheck:false (e.g. the default) but I have used skipLibCheck:true in a lot of my projects that consume libraries like @gmod/bam (not ideal, but a quick workaround for stuff like this)

@tuner
Copy link
Author

tuner commented May 25, 2023

Thanks, Colin! It seems that skipLibCheck skips those parts of library type definitions I'm not using anywhere, so, I think I can safely enable it for now.

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

2 participants