-
Notifications
You must be signed in to change notification settings - Fork 33
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
[BUG] Removing skipLibCheck throws an error #845
Comments
Hey @gogbog, thanks for submitting the issue. |
My rollup config was invalid, but clumsily working until a recent change in how we defined the event emitter type. The impact was the the bundled types for the web imported `from 'events'` instead of bundling it. This PR fixes the mis-configuration (see comments). Here is a screenshot showing the bundled types in the dist now (notice the import is gone and the emitter is in-lined, no other changes are present): ![image](https://github.com/open-feature/js-sdk/assets/25272906/8728911d-7c72-4d53-8dc2-d748837a616e) In server, this type is available from node, so we DON'T need to bundle it, and in fact, SHOULD import it. This is easily done by importing it like `from 'node:events'`. I don't think it would be a problem if we bundled it anyway, but this is more correct. Fixes: #845 Signed-off-by: Todd Baert <[email protected]>
<!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> Fixes an issue where the `events` node polyfill does not comply to the `node:events` types. When trying to use the web OpenFeatureEventEmitter the following error message comes up, describing that the `events` polyfill's EventEmitter is incompatible to `node:events` EventEmitter. ``` ✘ [ERROR] TS2416: Property 'eventEmitter' in type 'OpenFeatureEventEmitter' is not assignable to the same property in base type 'GenericEventEmitter<ProviderEmittableEvents, Record<string, unknown>>'. Type 'EventEmitter' is not assignable to type 'PlatformEventEmitter'. Types of property 'addListener' are incompatible. Type '(type: string | number, listener: Listener) => EventEmitter' is not assignable to type '(eventName: string | symbol, listener: (...args: any[]) => void) => PlatformEventEmitter'. Types of parameters 'type' and 'eventName' are incompatible. Type 'string | symbol' is not assignable to type 'string | number'. Type 'symbol' is not assignable to type 'string | number'. ``` This PR fixes that issue by not using the `events` anymore and instead using https://www.npmjs.com/package/eventemitter3 cc @toddbaert ### Related Issues <!-- add here the GitHub issue that this PR resolves if applicable --> Fixes #845 --------- Signed-off-by: Lukas Reining <[email protected]> Signed-off-by: Todd Baert <[email protected]> Co-authored-by: Todd Baert <[email protected]>
@gogbog This new version also has the benefit for totaling 220kB instead of 250kB |
@toddbaert @lukas-reining Thanks for the fast response. Everything worked as expected. I'm closing the issue. |
Observed behavior
We have a project where we want to use web-sdk and we already have a provider. When we try to use sdk in the project without the
--skipLibCheck
it doesn't compile.It throws the following error:
By installing
npm i --save-dev @types/events
, I'm getting the following error:Expected Behavior
There is no compile error, even tho the skipLibCheck is false.
Steps to reproduce
ng new angular-test
npm i @openfeature/web-sdk
import { OpenFeature } from '@openfeature/web-sdk'
The text was updated successfully, but these errors were encountered: