I’m currently developing an extension for JupyterLab. As part of this process, I’m utilizing the InversifyJS library from npm. To use it, I have to import ‘reflect-metadata’ in my index.ts file, which I have done. However, when I create an injectable class and use it in my extension, I encounter the following error:
TypeError: getOwnMetadataKeys is not a function
at Object.isProviderFor (Reflect.js:1135:1)
at getProviderNoCache (Reflect.js:941:1)
at Object.getProvider (Reflect.js:955:1)
at GetMetadataProvider (Reflect.js:1158:1)
at OrdinaryDefineOwnMetadata (Reflect.js:611:1)
at decorator (Reflect.js:195:1)
at DecorateConstructor (Reflect.js:549:1)
at Reflect.decorate (Reflect.js:143:1)
at push.../shared/components/localTelemetry.ts.__decorate (icons.ts:4:72)
at ../shared/components/localTelemetry.ts (localTelemetry.ts:7:28)
This is part of my code
@injectable()
export class LocalTelemetry implements TelemetryService {
constructor(
@inject(NAMES.customerId)
private customerId: string = '',
@inject(NAMES.outputChannelTelemetry)
private outputChannel: Logger
) {}
And I have imported the reflect-metadata at the index.ts 1st line.
Upon researching a solution for this error, the majority of sources suggest importing reflect-metadata at the root level file, which I have already done. I wrote Jest test cases for the Injectable class and the test cases are passing when I run them in the terminal. I’m uncertain about what I might be doing incorrectly.
manoj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.