question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type alias 'ExcludeFromTuple' circularly references itself.

See original GitHub issue

We are trying to use redux-toolkit in our stencil js, typescript project. Once we import the createAsyncThunk , I’m getting the below error.

[51:07.6] transpile started … [51:08.8] transpile finished in 1.20 s

[ ERROR ] TypeScript: …/…/node_modules/@reduxjs/toolkit/dist/tsHelpers.d.ts:43:21 Type alias ‘ExcludeFromTuple’ circularly references itself.

 L42:  export declare type IsUnknownOrNonInferrable<T, True, False> = AtLeastTS35<IsUnknown<T, True, False>, IsEmptyObj<T, True, IsUnknown<T, True, False>>>;
 L43:  export declare type ExcludeFromTuple<T, E, Acc extends unknown[] = []> = T extends [
 L44:      infer Head,

[ ERROR ] TypeScript: …/…/node_modules/@reduxjs/toolkit/dist/tsHelpers.d.ts:46:5 Type ‘ExcludeFromTuple’ is not generic.

 L45:      ...infer Tail
 L46:  ] ? ExcludeFromTuple<Tail, E, [...Acc, ...([Head] extends [E] ? [] : [Head])]> : Acc;
 L47:  declare type ExtractDispatchFromMiddlewareTuple<MiddlewareTuple extends any[], Acc extends {}> = MiddlewareTuple extends [infer Head, ...infer Tail] ? ExtractDispatchFromMiddlewareTuple<Tail, Acc & (Head extends Middleware<infer D, any> ? IsAny<D, {}, D> : {})> : Acc;

[ ERROR ] TypeScript: …/…/node_modules/@reduxjs/toolkit/dist/tsHelpers.d.ts:47:14 Type alias ‘ExtractDispatchFromMiddlewareTuple’ circularly references itself.

 L46:  ] ? ExcludeFromTuple<Tail, E, [...Acc, ...([Head] extends [E] ? [] : [Head])]> : Acc;
 L47:  declare type ExtractDispatchFromMiddlewareTuple<MiddlewareTuple extends any[], Acc extends {}> = Middlewa
 L48:  export declare type ExtractDispatchExtensions<M> = M extends MiddlewareArray<infer MiddlewareTuple> ? ExtractDispatchFromMiddlewareTuple<MiddlewareTuple, {}> : M extends Middleware[] ? ExtractDispatchFromMiddlewareTuple<[...M], {}> : never;

[ ERROR ] TypeScript: …/…/node_modules/@reduxjs/toolkit/dist/tsHelpers.d.ts:47:152 Type ‘ExtractDispatchFromMiddlewareTuple’ is not generic.

 L46:  ] ? ExcludeFromTuple<Tail, E, [...Acc, ...([Head] extends [E] ? [] : [Head])]> : Acc;
 L47:  uple<MiddlewareTuple extends any[], Acc extends {}> = MiddlewareTuple extends [infer Head, ...infer Tail]                                                                                                              
 L48:  export declare type ExtractDispatchExtensions<M> = M extends MiddlewareArray<infer MiddlewareTuple> ? ExtractDispatchFromMiddlewareTuple<MiddlewareTuple, {}> : M extends Middleware[] ? ExtractDispatchFromMiddlewareTuple<[...M], {}> : never;

[ ERROR ] TypeScript: …/…/node_modules/@reduxjs/toolkit/dist/getDefaultMiddleware.d.ts:26:36 Type ‘ExcludeFromTuple’ is not generic.

 L25:      serializableCheck: true;
 L26:  }>(options?: O) => MiddlewareArray<ExcludeFromTuple<[ThunkMiddlewareFor<S, O>], never>>;
 L27:  export declare function curryGetDefaultMiddleware<S = any>(): CurriedGetDefaultMiddleware<S>;

[51:08.8] build failed in 1.22 s

error Command failed with exit code 1.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
lindapaistecommented, Jun 29, 2022

This definitely sounds like a TypeScript versioning issue to me. Rest elements can be at any position in a tuple since TS 4.2. The circular references type issue if I think solved by 3.7.

I know that the Redux package has some built-in support for backwards compatibility with these newer features.

I have a theory about what your problem is. I think that you are running your transpile command with a different version of TS than what is specified in your package.json. If you are initiating the command through an IDE, make sure that the IDE settings have the correct TS version. Related SO answer.

0reactions
markeriksoncommented, Jul 1, 2022

I’m going to assume this is a project-specific build issue for now. If you do come up with a totally separate reproduction of the issue and it’s still happening, please comment and we can take a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type alias circularly references itself - Stack Overflow
Per the documentation, a type alias can refer to itself in a property, but not anywhere else on the right side of the...
Read more >
Type alias circularly references itself · Issue #14174 - GitHub
I'm trying to create a type that circularly references itself, but in a way that it makes sense - or at least it...
Read more >
Error TS2456: Type alias 'Awaited' circularly references itself
I have an error when adding angular instansearch module: Error: ../../../node_modules/instantsearch.js/es/types/utils.d.ts:12:21 - error ...
Read more >
Resolved type alias - Microsoft Learn
A narrower version of TypeScript 4.5's Awaited type which Recursively unwraps the "awaited type", emulating the behavior of await.
Read more >
error TS2456: Type alias 'Flattened' circularly references itself ...
The source project of this merge request has been removed. Bug fix: error TS2456: Type alias 'Flattened' circularly references itself.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found