-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: add TypeScript types #67
Conversation
These should be considered experimental. I'm not confident in my TypeScript typing.
open-telemetry/opentelemetry-js#3727 is my draft PR that would use these types. One possible concern are some of these linter warnings in the OTel repo:
For example, is that export type OnRequireFn = <T>(exports: T, name: string, basedir?: string) => T; ? |
Hi Trent, I've did a clean checkout of OTel repo and I did have the same warnings so the warnings you see are scoped in the printed files and your typings in So what about these warnings? The linter is mainly warning about the code using the type
Actually the TS compiler is complaining about a redundancy in generic types in the class definition. The class is defining a generic type in class type and also in a private method export abstract class InstrumentationBase<T = any>
extends InstrumentationAbstract
implements types.Instrumentation
{
// Some attributes & methods
private _onRequire<T>(
module: InstrumentationModuleDefinition<T>,
exports: T,
name: string,
baseDir?: string
): T {
// Implementation
}
} As you see we have a generic in the class definition If my observation is right just changing the generic name would be enough, something like the following would resolve the shadowing linter warning private _onRequire<ExportsType>(
module: InstrumentationModuleDefinition<ExportsType>,
exports: ExportsType,
name: string,
baseDir?: string
): ExportsType {
// Implementation
} Also IMHO out of scope of this task but we can be good boy scouts and ask the author of the code |
@david-luna Thanks for the review! I'll take open-telemetry/opentelemetry-js#3727 out of draft and give a chance for reviews there before merging this and doing another release with it. |
These should be considered experimental. I'm not confident in my
TypeScript typing.
These are based on the types from
@opentelemetry/instrumentation
: https://github.com/open-telemetry/opentelemetry-js/blob/v1.11.0/experimental/packages/opentelemetry-instrumentation/src/platform/node/require-in-the-middle.d.tschecklist
@opentelemetry/instrumentation
.