Skip to content
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

Support strict mode #870

Closed
corsairdnb opened this issue Sep 7, 2022 · 46 comments
Closed

Support strict mode #870

corsairdnb opened this issue Sep 7, 2022 · 46 comments

Comments

@corsairdnb
Copy link

corsairdnb commented Sep 7, 2022

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 typescript@4.8.2 (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

@MussaratAziz
Copy link

MussaratAziz commented Sep 21, 2022

any update? @corsairdnb @NetanelBasal Thank you

@peternixey
Copy link

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


@MussaratAziz
Copy link

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.

LazeKer added a commit to LazeKer/akita that referenced this issue Oct 13, 2022
Update NW workspace to version 14 upgrading angular to the same version and typescript up to 4.8

Closes salesforce#870
@snebjorn
Copy link
Contributor

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

@LazeKer
Copy link

LazeKer commented Oct 13, 2022

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

@MussaratAziz
Copy link

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

@simeyla
Copy link

simeyla commented Oct 21, 2022

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).

@Ketec
Copy link

Ketec commented Nov 11, 2022

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?

@simeyla
Copy link

simeyla commented Nov 11, 2022

@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 :-)

@Ketec
Copy link

Ketec commented Dec 5, 2022

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.

@nerumo
Copy link
Contributor

nerumo commented Dec 5, 2022

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?

@jgomesmv
Copy link

jgomesmv commented Dec 5, 2022

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: #946

nerumo added a commit to nerumo/akita that referenced this issue Dec 9, 2022
Update NW workspace to version 14 upgrading angular to the same version and typescript up to 4.8

Closes salesforce#870
@nerumo nerumo mentioned this issue Dec 9, 2022
1 task
@nerumo
Copy link
Contributor

nerumo commented Dec 9, 2022

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

@nerumo
Copy link
Contributor

nerumo commented Dec 9, 2022

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
Copy link
Contributor

nerumo commented Dec 13, 2022

ngneat/elf#409

@jimjag jimjag closed this as completed in 4cc4d9a Dec 13, 2022
@nerumo
Copy link
Contributor

nerumo commented Dec 13, 2022

thank you @jimjag

@Ketec
Copy link

Ketec commented Dec 14, 2022

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.

@Donnerstagnacht
Copy link

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

@WynieCronje
Copy link

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

@Ketec
Copy link

Ketec commented Jan 10, 2023

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.

@NetanelBasal
Copy link
Collaborator

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

@Ketec
Copy link

Ketec commented Jan 10, 2023

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.

@WynieCronje
Copy link

WynieCronje commented Jan 10, 2023

I have the same Issue with version 8

image

@NetanelBasal
Copy link
Collaborator

#870 (comment)

@jorgenfb
Copy link

@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

@Ketec
Copy link

Ketec commented Jan 10, 2023

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.

@NetanelBasal
Copy link
Collaborator

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 NetanelBasal reopened this Jan 10, 2023
@NetanelBasal NetanelBasal changed the title Akita-ng-entity-service incompatible with Typescript 4.8 and Angular 14.2 Support strict mode Jan 10, 2023
@NetanelBasal NetanelBasal pinned this issue Jan 10, 2023
@jorgenfb
Copy link

@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.

@rodro75
Copy link

rodro75 commented Jan 10, 2023

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.

@hakimio
Copy link

hakimio commented Jan 10, 2023

@rodro75 after commit c9af3ea RxJS v6 is no longer supported. You have to upgrade to v7.

@NetanelBasal
Copy link
Collaborator

You can upgrade to rxjs v7. It should be seamless

@rodro75
Copy link

rodro75 commented Jan 10, 2023

Ooops! Didn't notice that.
Ok thank you, now it compiles again!

@nunoarruda
Copy link

Yeah, Angular 15 + Akita 8 is not compiling:

Screenshot 2023-01-30 at 14 02 53

I'm also not willing to turn off strict mode or/and set skipLibCheck to true.

I don't see a PR to fix this. I might try and give it a stab. No promises though.

@Ketec
Copy link

Ketec commented Jan 30, 2023

The only place where i "fixed" it is in my own code where I extended the store/query for additional methods.
So the fix could be either increase type coverage or make it even more generic.

But the types do get quite extensive and complex ex:

@Injectable({ providedIn: 'root'})
export abstract class BaseQuery<S, EntityType = getEntityType<S>, IDType = getIDType<S>> extends QueryEntity<EntityState<EntityType, IDType>> {
  public getEntityByUuid(id: string): EntityType | undefined {
    return this.getAll({
      filterBy: (entity: any) => entity?.uuid === id,
      limitTo: 1
    }).pop();
  }
}

Den-dp added a commit to Den-dp/akita that referenced this issue Jan 31, 2023
This is a quick spike created to find out a way to fix akita for Angular 15+ in strict mode

Refs: salesforce#870
@Den-dp
Copy link
Contributor

Den-dp commented Jan 31, 2023

@nunoarruda the first thing I've tried is to enable strict: true for this monorepo and fix them - but the amount of errors in such case is pretty significant 🥵

After that, I tried to fix only TS errors that I found while consuming akita@8.0.0 in my project. And such approach helped me to decrease the API surface to a couple of places, which was somehow fixed in this draft/spike #1050.

Interestingly, #1050 already allowed me to consume akita in Angular 15 project with a strict mode (and without skipLibCheck).

But unfortunately:

  1. I'm not confident in these TS-related changes (don't have a big project to test on)
  2. I want to find a proper tsconfig configuration that will help with the reproduction of the initial issue for future contributors

So any recommendations on these 2 subjects are welcome!

Also, I'm totally ok if someone wants to use my spike to fix this issue ❤️

Den-dp added a commit to Den-dp/akita that referenced this issue Feb 5, 2023
This is a quick spike created to find out a way to fix akita for Angular 15+ in strict mode

Refs: salesforce#870
Den-dp added a commit to Den-dp/akita that referenced this issue Feb 12, 2023
This PR makes the public API of Akita to be consumable in a strict typescript project

Refs: salesforce#870
@nunoarruda
Copy link

Hey @NetanelBasal, there's a PR available: #1050

When you have a chance, can you please review and possibly merge and release? This would unblock folks trying to use Akita v8 with Angular 15 and/or strict mode.

Thanks in advance 👍

NetanelBasal pushed a commit that referenced this issue Feb 13, 2023
* fix(akita): support TS strict mode

This PR makes the public API of Akita to be consumable in a strict typescript project

Refs: #870

* chore(general): fix deps graph to fix build:all

Add `dependsOn` for `build` to build dependencies of a project first before building the project
Remove "nx/presets/npm.json" to fix deps graph (cause it disabled the analyzeSourceFiles feature)
@NetanelBasal
Copy link
Collaborator

I've released v8.0.1, please check and verify the fix so we can close the issue.

@Hatooz
Copy link

Hatooz commented Feb 14, 2023

hello, its compiles fine now, but am getting error with schematics when trying to add components or stores etc:
Package "@datorama/akita" was found but does not support schematics.
Angular 15
Akita 8.0.1

@Den-dp
Copy link
Contributor

Den-dp commented Feb 14, 2023

@Hatooz I found in the changelog that this breaking change was a part of the previous 8.0.0 release https://github.com/salesforce/akita/blob/master/packages/akita/CHANGELOG.md#800-2023-01-09

@WynieCronje
Copy link

For me it works. No more type errors.

@xjuanc
Copy link

xjuanc commented Mar 10, 2023

I'm getting a kind of similar error, any idea why this one could be?

Screenshot 2023-03-10 at 21 17 24

@Ketec
Copy link

Ketec commented Mar 10, 2023

RXJs version. it requires 7, you use 6 (distinctUntilChanged was under rxjs/operators before)

@xjuanc
Copy link

xjuanc commented Mar 10, 2023

RXJs version. it requires 7, you use 6 (distinctUntilChanged was under rxjs/operators before)

Wow, sorry for such an stupid error, my bad, fixed it by updating RXJS to v7. Thought Angular made it with the ng upgrade... Thanks!!

@tideee2
Copy link

tideee2 commented Mar 13, 2023

Someone can help?
I updated angular to v.15.2 an got an error after build in runtime

TypeError: Class constructor EntityStore cannot be invoked without 'new'
    at new FavoritesStore (favorites.store.ts:11:5)
    at Object.FavoritesStore_Factory [as factory] (favorites.store.ts:12:3)
    at R3Injector.hydrate (core.mjs:8020:35)
    at R3Injector.get (core.mjs:7908:33)
    at injectInjectorOnly (core.mjs:633:33)
    at Module.ɵɵinject (core.mjs:637:60)
    at Object.FavoritesService_Factory [as factory] (favorites.service.ts:15:30)
    at R3Injector.hydrate (core.mjs:8020:35)
    at R3Injector.get (core.mjs:7908:33)
    at ChainedInjector.get (core.mjs:12077:36)

my store:

   export interface FavoritesState extends EntityState<Facility> {}

@Injectable({ providedIn: 'root' })
@StoreConfig({ name: 'favorites' })
export class FavoritesStore extends EntityStore<FavoritesState> {
  constructor() {
    super();
  }
}

typescript: 4.8.4
akita: 8.0.1
angular: 15.2.2

@Den-dp
Copy link
Contributor

Den-dp commented Mar 14, 2023

@tideee2 to me it looks like an angular-cli (typescript/babel) misconfiguration

Try copying your code into a newly created Angular project. Share your repro if error will remain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests