akita icon indicating copy to clipboard operation
akita copied to clipboard

Akita-ng-entity-service incompatible with Typescript 4.8 and Angular 14.2

Open corsairdnb opened this issue 2 years ago • 1 comments

Is this a regression?

No

Description

When trying to run Angular build or tests got following errors:

Error: node_modules/@datorama/akita/src/lib/entityStore.d.ts:262:83 - error TS2344: Type 'UIState' does not satisfy the constraint 'EntityState<any, any>'.

262 export declare class EntityUIStore<UIState, DEPRECATED = any> extends EntityStore<UIState> {
                                                                                      ~~~~~~~

  node_modules/@datorama/akita/src/lib/entityStore.d.ts:262:36
    262 export declare class EntityUIStore<UIState, DEPRECATED = any> extends EntityStore<UIState> {
                                           ~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/plugins/plugin.d.ts:3:65 - error TS2344: Type 'State' does not satisfy the constraint 'EntityState<any, any>'.

............

Steps to reproduce:

  1. npx @angular/cli new project (>=14.2.0 version expected to install)
  2. npm i [email protected] (check that typescript >=4.8 installed)
  3. ng add @datorama/akita
  4. ng g m session
  5. ng g c session/signup
  6. ng g af session/session --plain
  7. add code to AppComponent: constructor(private sessionService: SessionService) {}
  8. run npm run test or npm run build

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Error: node_modules/@datorama/akita/src/lib/entityStore.d.ts:262:83 - error TS2344: Type 'UIState' does not satisfy the constraint 'EntityState<any, any>'.

262 export declare class EntityUIStore<UIState, DEPRECATED = any> extends EntityStore<UIState> {
                                                                                      ~~~~~~~

  node_modules/@datorama/akita/src/lib/entityStore.d.ts:262:36
    262 export declare class EntityUIStore<UIState, DEPRECATED = any> extends EntityStore<UIState> {
                                           ~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/plugins/plugin.d.ts:3:65 - error TS2344: Type 'State' does not satisfy the constraint 'EntityState<any, any>'.

3 export declare type Queries<State> = Query<State> | QueryEntity<State>;
                                                                  ~~~~~

  node_modules/@datorama/akita/src/lib/plugins/plugin.d.ts:3:29
    3 export declare type Queries<State> = Query<State> | QueryEntity<State>;
                                  ~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/queryEntity.d.ts:251:83 - error TS2344: Type 'UIState' does not satisfy the constraint 'EntityState<any, any>'.

251 export declare class EntityUIQuery<UIState, DEPRECATED = any> extends QueryEntity<UIState> {
                                                                                      ~~~~~~~

  node_modules/@datorama/akita/src/lib/queryEntity.d.ts:251:36
    251 export declare class EntityUIQuery<UIState, DEPRECATED = any> extends QueryEntity<UIState> {
                                           ~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:30:73 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

30 export declare function getEntityStore<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : never>(storeClass: Constructor<TEntityStore>): TEntityStore;
                                                                           ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:30:77
    30 export declare function getEntityStore<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : never>(storeClass: Constructor<TEntityStore>): TEntityStore;
                                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:35:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

35 export declare function getEntityStoreByName<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : never>(storeName: string): TEntityStore;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:35:83
    35 export declare function getEntityStoreByName<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : never>(storeName: string): TEntityStore;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:57:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

57 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.SetEntities, operation: (operator: TEntityStore['set']) => void): any;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:57:83
    57 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.SetEntities, operation: (operator: TEntityStore['set']) => void): any;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:68:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

68 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.AddEntities, operation: (operator: TEntityStore['add']) => void): any;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:68:83
    68 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.AddEntities, operation: (operator: TEntityStore['add']) => void): any;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:79:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

79 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.UpdateEntities, operation: (operator: TEntityStore['update']) => void): any;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:79:83
    79 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.UpdateEntities, operation: (operator: TEntityStore['update']) => void): any;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:90:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

90 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.RemoveEntities, operation: (operator: TEntityStore['remove']) => void): any;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:90:83
    90 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.RemoveEntities, operation: (operator: TEntityStore['remove']) => void): any;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:101:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

101 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.UpsertEntities, operation: (operator: TEntityStore['upsert']) => void): any;
                                                                                  ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:101:83
    101 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.UpsertEntities, operation: (operator: TEntityStore['upsert']) => void): any;
                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:114:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

114 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.UpsertManyEntities, operation: (operator: TEntityStore['upsertMany']) => void): any;
                                                                                  ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:114:83
    114 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.UpsertManyEntities, operation: (operator: TEntityStore['upsertMany']) => void): any;
                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.

Please provide the environment you discovered this bug in

Typescript 4.8.2
Angular 14.2.0
Node 16.5.1
Npm 8.11.0
MacOS 12.5.1

Anything else?

This issue is a blocker for using latest Angular with Akita

Do you want to create a pull request?

No

corsairdnb avatar Sep 07 '22 10:09 corsairdnb

any update? @corsairdnb @NetanelBasal Thank you

MussaratAziz avatar Sep 21 '22 12:09 MussaratAziz

Just to add a little more flavour...

I have just been upgrading and saw the following


Akita 7.1.1 Angular 14.2.2 Typescript 4.7.4 ✅ Akita all works fine


Akita 7.1.1 Angular 14.2.2 Typescript ~~4.7.4~~ 4.8.4 ❌ As per the errors above


peternixey avatar Sep 28 '22 12:09 peternixey

Just to add a little more flavour...

I have just been upgrading and saw the following

Akita 7.1.1 Angular 14.2.2 Typescript 4.7.4 ✅ Akita all works fine

Akita 7.1.1 Angular 14.2.2 Typescript ~4.7.4~ 4.8.4 ❌ As per the errors above

its typescript 4.6 also working fine.

MussaratAziz avatar Sep 29 '22 07:09 MussaratAziz

found this in the change log for Angular 15

TypeScript versions older than 4.8.2 are no longer supported.

So TypeScript 4.8+ support will quickly become very important

snebjorn avatar Oct 13 '22 07:10 snebjorn

found this in the change log for Angular 15

TypeScript versions older than 4.8.2 are no longer supported.

So TypeScript 4.8+ support will quickly become very important

Agreed! I opened a PR but the CLA system don't like me much

LazeKer avatar Oct 13 '22 07:10 LazeKer

@NetanelBasal please have a look at the PR from @LazeKer.

MussaratAziz avatar Oct 17 '22 15:10 MussaratAziz

Has anyone already on this thread made the necessary changes for themselves?

I just spent all day updating to Angular 14 and I thought I was going to attempt to update Akita myself but decided for now I'm reverting to TS 4.7.4 (thanks to @MussaratAziz for this version tip).

simeyla avatar Oct 21 '22 01:10 simeyla

Just run into this as well. It's been over a month since this was reported. Is Akita not maintained anymore? Should we start looking and migrating to alternatives?

Ketec avatar Nov 11 '22 14:11 Ketec

@Ketec it's definitely been superseded by Elf from the same author

But it's probably impractical for most to update to it - at least for a working project.

@NetanelBasal hope all is well. Do you think you'll be able to update the typescript definitions anytime soon? As you know Angular 15 is imminent. It would really 'satisfies' many of us if we could use TS 4.9 :-)

simeyla avatar Nov 11 '22 19:11 simeyla

Guess this can be considered deprecated and the repository should be marked as such. It is now incompatible with the latest Angular.

If there has still been no response in another 3+ weeks.

Ketec avatar Dec 05 '22 08:12 Ketec

There's a PR lying around. When there's still people carrying about it, it's not yet abandoned. It's just a transition phase. I saw that in many projects which are still not dead yet. But of course, I'd also like to a see the owner to either find a new owner (or add new maintainers) or actively maintain it. Regarding the CLA issue: does signing it with your primary email work?

nerumo avatar Dec 05 '22 08:12 nerumo

There's a PR lying around. When there's still people carrying about it, it's not yet abandoned. It's just a transition phase. I saw that in many projects which are still not dead yet. But of course, I'd also like to a see the owner to either find a new owner (or add new maintainers) or actively maintain it. Regarding the CLA issue: does signing it with your primary email work?

I guess this is the PR you mention: https://github.com/salesforce/akita/pull/946

jgomesmv avatar Dec 05 '22 09:12 jgomesmv

I tried it with my github account, same problem :( Commit authors must be associated with GitHub users

nerumo avatar Dec 09 '22 12:12 nerumo

I tried it with my github account, same problem :( Commit authors must be associated with GitHub users

ah, I finally found the issue. I had to push a new commit so the signed CLA was found. But I'm afraid that this still won't get any attention from the maintainers

nerumo avatar Dec 09 '22 19:12 nerumo

https://github.com/ngneat/elf/pull/409

nerumo avatar Dec 13 '22 08:12 nerumo

thank you @jimjag

nerumo avatar Dec 13 '22 20:12 nerumo

So I see it's merged now. But no new release version - I assume this still needs manual builds/tagging/promotion? the latest is 7.1.1 from January.

@jimjag any updates on the actual new build after merge since this issue was closed - but the fixes are not actually available.

https://github.com/salesforce/akita/actions/runs/3657434264 is waiting for approval.

Ketec avatar Dec 14 '22 07:12 Ketec

Is there any news when a new version will be published? Or can I update Akita manually?

Donnerstagnacht avatar Dec 20 '22 21:12 Donnerstagnacht

@Donnerstagnacht It seems like a new version was published... I'm going to try it out soon

WynieCronje avatar Jan 10 '23 06:01 WynieCronje

The peerDep got set to 15+ so it's not available for 14 (can locally force it to install but will not work for cicd/prod builds like that). And it still has type errors with Typescript 4.8.4.


Error: node_modules/@datorama/akita/src/lib/entityStore.d.ts:262:83 - error TS2344: Type 'UIState' does not satisfy the constraint 'EntityState<any, any>'.

262 export declare class EntityUIStore<UIState, DEPRECATED = any> extends EntityStore<UIState> {
                                                                                      ~~~~~~~

  node_modules/@datorama/akita/src/lib/entityStore.d.ts:262:36
    262 export declare class EntityUIStore<UIState, DEPRECATED = any> extends EntityStore<UIState> {
                                           ~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/plugins/plugin.d.ts:3:65 - error TS2344: Type 'State' does not satisfy the constraint 'EntityState<any, any>'.

3 export declare type Queries<State> = Query<State> | QueryEntity<State>;
                                                                  ~~~~~

  node_modules/@datorama/akita/src/lib/plugins/plugin.d.ts:3:29
    3 export declare type Queries<State> = Query<State> | QueryEntity<State>;
                                  ~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/queryEntity.d.ts:251:83 - error TS2344: Type 'UIState' does not satisfy the constraint 'EntityState<any, any>'.

251 export declare class EntityUIQuery<UIState, DEPRECATED = any> extends QueryEntity<UIState> {
                                                                                      ~~~~~~~

  node_modules/@datorama/akita/src/lib/queryEntity.d.ts:251:36
    251 export declare class EntityUIQuery<UIState, DEPRECATED = any> extends QueryEntity<UIState> {
                                           ~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:30:73 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

30 export declare function getEntityStore<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : never>(storeClass: Constructor<TEntityStore>): TEntityStore;
                                                                           ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:30:77
    30 export declare function getEntityStore<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : never>(storeClass: Constructor<TEntityStore>): TEntityStore;
                                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:35:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

35 export declare function getEntityStoreByName<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : never>(storeName: string): TEntityStore;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:35:83
    35 export declare function getEntityStoreByName<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : never>(storeName: string): TEntityStore;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:57:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

57 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.SetEnt
ities, operation: (operator: TEntityStore['set']) => void): any;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:57:83
    57 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.Se
tEntities, operation: (operator: TEntityStore['set']) => void): any;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:68:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

68 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.AddEnt
ities, operation: (operator: TEntityStore['add']) => void): any;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:68:83
    68 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.Ad
dEntities, operation: (operator: TEntityStore['add']) => void): any;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:79:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

79 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.Update
Entities, operation: (operator: TEntityStore['update']) => void): any;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:79:83
    79 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.Up
dateEntities, operation: (operator: TEntityStore['update']) => void): any;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:90:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

90 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.Remove
Entities, operation: (operator: TEntityStore['remove']) => void): any;
                                                                                 ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:90:83
    90 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.Re
moveEntities, operation: (operator: TEntityStore['remove']) => void): any;
                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.


Error: node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:101:79 - error TS2344: Type 'S' does not satisfy the constraint 'EntityState<any, any>'.

101 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.Upser
tEntities, operation: (operator: TEntityStore['upsert']) => void): any;
                                                                                  ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:101:83
    101 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.U
114 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.Upser
tManyEntities, operation: (operator: TEntityStore['upsertMany']) => void): any;
                                                                                  ~

  node_modules/@datorama/akita/src/lib/runStoreAction.d.ts:114:83
    114 export declare function runEntityStoreAction<TEntityStore extends EntityStore<S>, S = TEntityStore extends EntityStore<infer T> ? T : any>(storeClassOrName: Constructor<TEntityStore> | string, action: EntityStoreAction.U
psertManyEntities, operation: (operator: TEntityStore['upsertMany']) => void): any;
                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends EntityState<any, any>` constraint.

Ketec avatar Jan 10 '23 07:01 Ketec

I'm wondering why it's not happening in the repo. It uses v4.8.

NetanelBasal avatar Jan 10 '23 08:01 NetanelBasal

The playground? Perhaps because it's not consuming akita from installed distribution but locally in the nx workspace?

I'll need to set up and test with a separate clean project to validate.

Ketec avatar Jan 10 '23 08:01 Ketec

I have the same Issue with version 8

image

WynieCronje avatar Jan 10 '23 09:01 WynieCronje

https://github.com/salesforce/akita/issues/870#issuecomment-1376869652

NetanelBasal avatar Jan 10 '23 09:01 NetanelBasal

@NetanelBasal I think it happens due to stricter compilation options. If I try to build akita with the option "strictFunctionTypes": true (in tsconfig.base.json) I get similar errors:

image

jorgenfb avatar Jan 10 '23 10:01 jorgenfb

A workaround for people having this issue is to skip type checking declaration files.

You can do this by adding this to your tsconfig:

"skipLibCheck": true,

Documentation for this compiler flag: https://www.typescriptlang.org/tsconfig#skipLibCheck

Warning: Be aware that this reduces type-system accuracy and should not be considered a permanent solution.

jorgenfb avatar Jan 10 '23 10:01 jorgenfb

skipLibCheck also disables checking even for your own libraries or any declaration fields inside the project. You can't specify where it applies. Hiding errors and reducing code quality and adding the option for poor-quality code is not a workaround.

Ketec avatar Jan 10 '23 10:01 Ketec

Yes, it seems like changing to strict causes many errors. I'm sorry, but I don't have time to work on this for now. It'll be great if someone wants to create a PR to support a strict mode in typescript.

NetanelBasal avatar Jan 10 '23 11:01 NetanelBasal

@Ketec I appreciate your input. I have added a warning to my comment to explain that this reduces the type checking accuracy. I will still leave it as a workaround to allow people to decide them self.

jorgenfb avatar Jan 10 '23 11:01 jorgenfb

Hi guys, I just stumbled on this problem while you were resuming the discussion. I already tried the dirty hack of skipLibChecks=true, but now the compilation fails for a different reason.

./node_modules/@datorama/akita/src/lib/arrayFind.js:28:9-29 - Error: export 'distinctUntilChanged' (imported as 'distinctUntilChanged') was not found in 'rxjs' (possible exports: ArgumentOutOfRangeError, AsyncSubject, BehaviorSubject, ConnectableObservable, EMPTY, EmptyError, GroupedObservable, NEVER, Notification, NotificationKind, ObjectUnsubscribedError, Observable, ReplaySubject, Scheduler, Subject, Subscriber, Subscription, TimeoutError, UnsubscriptionError, VirtualAction, VirtualTimeScheduler, animationFrame, animationFrameScheduler, asap, asapScheduler, async, asyncScheduler, bindCallback, bindNodeCallback, combineLatest, concat, config, defer, empty, forkJoin, from, fromEvent, fromEventPattern, generate, identity, iif, interval, isObservable, merge, never, noop, observable, of, onErrorResumeNext, pairs, partition, pipe, queue, queueScheduler, race, range, 
scheduled, throwError, timer, using, zip)

and many more operators. My rxjs version is ~6.6.0 as it's always been.

I just wanted to let you know. I will postpone the update of Angular for now.

Thank you.

rodro75 avatar Jan 10 '23 11:01 rodro75