feathersjs-ecosystem / feathers-reactive

Reactive API extensions for Feathers services
MIT License
216 stars 37 forks source link

Error: Cannot find namespace 'sift'. #215

Open rmanibus opened 1 year ago

rmanibus commented 1 year ago

Steps to reproduce

Add this library to a typescript angular project And configure feathers with rx:

import { feathers} from '@feathersjs/feathers';
import { rx } from 'feathers-reactive';
       feathers().
      .configure(
        rx({
          idField: '_id',
        })

Expected behavior

Tell us what should happen feathers is configured properly

Actual behavior

Error: ../node_modules/feathers-reactive/dist/index.d.ts:76:61 - error TS2503: Cannot find namespace 'sift'.

76     var sift: <TItem, TSchema extends TItem = TItem>(query: sift.Query<TSchema>, options?: Partial<sift_lib_core.Options>) => (item: unknown, key?: sift_lib_utils.Key, owner?: any) => boolean;

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):

NodeJS version: v18.17.0

Operating System:

Browser Version:

React Native Version:

Module Loader:

bitflower commented 1 year ago

Hi @rmanibus

thanks for posting this.

May I ask for a repro repo? I doubt there will be the time to set this up and also to reduce the risk of using some other setup then you.

Thanks! Matthias

rmanibus commented 1 year ago

sure: https://github.com/rmanibus/feathers-reactive_reproducer_215

just run npm install then npm start

pit999 commented 1 year ago

I get the same error while compiling the module. I have to add import * as sift from 'sift'; This solves the problem.

serghienco commented 3 weeks ago

i have same error, is there a solution ? import * as sift from 'sift'; did not help

pit999 commented 2 weeks ago

i have same error, is there a solution ? import * as sift from 'sift'; did not help

In which file do you add the import statement?

serghienco commented 2 weeks ago

i have same error, is there a solution ? import * as sift from 'sift'; did not help

In which file do you add the import statement?

in the same file where rx is imported

import * as sift from 'sift'; import { rx } from 'feathers-reactive';

pit999 commented 2 weeks ago

You have to add the line in file node_module\feathers-reactive\dist\index.d.ts import { Application, FeathersService, Id, NullableId, Paginated, Params, Service } from '@feathersjs/feathers'; import { Observable, OperatorFunction } from 'rxjs'; *import as sift from 'sift';* import as sift_lib_core from 'sift/lib/core'; import * as sift_lib_utils from 'sift/lib/utils';

serghienco commented 2 weeks ago

You have to add the line in file node_module\feathers-reactive\dist\index.d.ts import { Application, FeathersService, Id, NullableId, Paginated, Params, Service } from '@feathersjs/feathers'; import { Observable, OperatorFunction } from 'rxjs'; *import as sift from 'sift';* import as sift_lib_core from 'sift/lib/core'; import * as sift_lib_utils from 'sift/lib/utils';

Thank you for the help! node_module* directory is created by npm install , developers should not change anything there, how do you do this change ? is possible to deploy to production this type of change ?

serghienco commented 2 weeks ago

You have to add the line in file node_module\feathers-reactive\dist\index.d.ts import { Application, FeathersService, Id, NullableId, Paginated, Params, Service } from '@feathersjs/feathers'; import { Observable, OperatorFunction } from 'rxjs'; *import as sift from 'sift';* import as sift_lib_core from 'sift/lib/core'; import * as sift_lib_utils from 'sift/lib/utils';

Thank you for the help! node_module* directory is created by npm install , developers should not change anything there, how do you do this change ? is possible to deploy to production this type of change ?

I was able to create postinstall script which always patch feathers-reactive library after install: "scripts": { "postinstall": "node ./scripts/patch-feathers-reactive.js" }

patch-feathers-reactive.js reads content of .\node_module\feathers-reactive\dist\index.d.ts and add in the begginig "import * as sift from 'sift';" only if missing

Thank you @pit999 for the help!

pit999 commented 1 week ago

I freezed the version in package.json of feathers-reactive (no changes since one year). Best solution would be to add this statement in the code by daffl :-)

daffl commented 1 week ago

This is an open source project. A pull request with the fixes can be made by anybody.

pit999 commented 1 week ago

Ok, I thought if I create an issue the issue will be solved :-) I never created a pull request, but I'm willing to learn this. But I checked the code and I'm not able to identify the .ts file where I have to add the import statement so that the line will be added to the feathers-reactive\dist\index.d.ts file :-o.