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 'unique symbol' cannot be used to index type 'Component'.

See original GitHub issue

Bug report

Describe the bug

When I use npm run build, following error appears:

nr build

> realworld@0.0.0 build /Users/tyankatsu/project/realworld
> tsc && vite build

node_modules/@stitches/react/types/index.d.ts:42:70 - error TS2536: Type 'unique symbol' cannot be used to index type 'Component'.

42 export type VariantProps<Component> = StyledComponent.TransformProps<Component[StyledComponent.$$StyledComponentProps], Component[StyledComponent.$$StyledComponentMedia]>
                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@stitches/react/types/index.d.ts:42:121 - error TS2536: Type 'unique symbol' cannot be used to index type 'Component'.

42 export type VariantProps<Component> = StyledComponent.TransformProps<Component[StyledComponent.$$StyledComponentProps], Component[StyledComponent.$$StyledComponentMedia]>
                                                                                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 2 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! realworld@0.0.0 build: `tsc && vite build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the realworld@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tyankatsu/.npm/_logs/2021-09-02T13_57_06_027Z-debug.log

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to https://github.com/tyankatsu0105/realworld/tree/4b53223aac598d5eee5af07dc3939c671b07da1e
  2. run npm run build
  3. See error

Expected behavior

Succeed to build.

System information

  • OS: macOS
  • Version of Stitches: 1.0.0
  • Version of Node.js: 12.22.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
rothsandrocommented, Oct 24, 2021

I have the same error in a Angular 12 project. It works when I update TypeScript from 4.3 to 4.4 (see release notes). But this not officially supported by Angular 12, I need to add disableTypeScriptVersionCheck: true in my tsconfig.

As a better workaround I added skipLibCheck: true in my tsconfig.

{
  "compilerOptions": {
    // ...
    "skipLibCheck": true
  }
}
1reaction
lukemartincommented, Sep 8, 2021

@peduarte 👋

Unfortunately that still doesn’t seem to work 😕

Errors: image

package.json here: https://github.com/lukemartin/gql-share/blob/stitches/package.json

Let me know if there’s anything else I can do to help ✌️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type 'symbol' cannot be used as an index type. #24587 - GitHub
test I added the property [key: string]: any; to the interface. With typescript 2.9.x this will result in Type 'unique symbol' cannot be...
Read more >
TS2538: Type 'unique symbol' cannot be used as an index type
My poor workaround : const bar: Record<any, string> = {}; const FOO = Symbol('foo'); // eslint-disable-next-line ...
Read more >
Microsoft/TypeScript - Gitter
Type 'unique symbol' cannot be used as an index type ... You can only use the unique symbol as an indexer if it's...
Read more >
Type 'X' cannot be used as an index type in TypeScript
The error "Type cannot be used as an index type" occurs when we try to use a type that cannot be used to...
Read more >
Symbol and Unique Symbol - Educative.io
A unique symbol can only be defined with the use of const or readonly static . A unique symbol is used to create...
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