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

fix: Move @types/generic-pool from dependencies to devDependencies #1563

Closed
wants to merge 1 commit into from
Closed

Conversation

secondfry
Copy link

@secondfry secondfry commented Jul 10, 2023

Which problem is this PR solving?

@opentelemetry/auto-instrumentations-node is unusable with TypeScript 5 due to following error:

> tsc && tsc-alias && touch .ok

error TS2688: Cannot find type definition file for 'generic-pool'.
  The file is in the program because:
    Entry point for implicit type library 'generic-pool'


Found 1 error.

Honesly, this fix is untested, but makes the most sense.

Short description of the changes

Move @types/generic-pool from dependencies to devDependencies.

@secondfry secondfry requested a review from a team July 10, 2023 19:14
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 10, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@github-actions github-actions bot requested a review from rauno56 July 10, 2023 19:14
@secondfry secondfry changed the title Move @types/generic-pool from dependencies to devDependencies fix: Move @types/generic-pool from dependencies to devDependencies Jul 10, 2023
@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

Merging #1563 (f2d8055) into main (a18b074) will decrease coverage by 3.42%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1563      +/-   ##
==========================================
- Coverage   96.06%   92.64%   -3.42%     
==========================================
  Files          14       86      +72     
  Lines         914     3874    +2960     
  Branches      199      705     +506     
==========================================
+ Hits          878     3589    +2711     
- Misses         36      285     +249     

see 100 files with indirect coverage changes

@@ -63,7 +64,6 @@
"dependencies": {
"@opentelemetry/instrumentation": "^0.40.0",
"@opentelemetry/semantic-conventions": "^1.0.0",
"@types/generic-pool": "^3.1.9",
Copy link
Member

Choose a reason for hiding this comment

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

Currently this package actually has to be a regular dependency as a type from this package is exported publicly from the package index.d.ts.

For end users installing this instrumentation in there application, typescript will attempt to import types from index.d.ts, as specified in package.json ):

  "types": "build/src/index.d.ts",

It will find this content in index.d.ts:

import GenericPoolInstrumentation from './instrumentation';
export { GenericPoolInstrumentation };
export default GenericPoolInstrumentation;
//# sourceMappingURL=index.d.ts.map

And will follow import GenericPoolInstrumentation from './instrumentation'; and find the following content in instrumentation.d.ts:

import { InstrumentationBase, InstrumentationConfig, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
import type * as genericPool from 'generic-pool';
export default class Instrumentation extends InstrumentationBase<typeof genericPool> {
    private _isDisabled;
    constructor(config?: InstrumentationConfig);
    init(): (InstrumentationNodeModuleDefinition<typeof genericPool> | InstrumentationNodeModuleDefinition<any>)[];
    private _acquirePatcher;
    private _poolWrapper;
    private _acquireWithCallbacksPatcher;
}
//# sourceMappingURL=instrumentation.d.ts.map

Once it hit the line

import type * as genericPool from 'generic-pool';

Typescript will emit an error as the types are missing.

You can follow this documentation to fix the issue. Basically what you need to do is to remove import type * as genericPool from 'generic-pool'; from instrumentation.ts and replace typeof genericPool in code with any.

@blumamir
Copy link
Member

@secondfry - are you still interested in this?
Should we keep the PR open?

@blumamir
Copy link
Member

fixed in #1637

@blumamir blumamir closed this Aug 16, 2023
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.

3 participants