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.

Typescript error when using utils with array input prop

See original GitHub issue

Bug report

Describe the bug

When using an util in the stitches config that has an input prop of type: value: [Stitches.ScaleValue<"colors">, number]) there is a typescript error when trying to use that util e.g. colorUtil: ["$red", 0.5] the error is Type ‘string’ is not assignable to type ‘ScaleValue<“colors”>’ on the $red part, The really weird thing is that autocompletes works correctly and offers the correct $red option.

To Reproduce

Here is a code sandbox reproducing the error, wait for the sandbox to be fully loaded and the error will appear on line 13 https://codesandbox.io/s/late-glade-9wxlt?file=/src/App.tsx:238-262 This is a fork of the base stitches code sandbox I found online. I upgraded dependencies to latest typescript and stitches

Expected behavior

No typescript error

Screenshots

issue

System information

  • OS: macOs
  • Version of Stitches: 1.0.0
  • Version of Node.js: 14

Additional context

It looks like the typescript version doesn’t change the result.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
berkaeycommented, Oct 17, 2021

Btw, it also won’t work with PropertyValue.

type TypographyToken = {
  family: PropertyValue<"fontFamily">;
  size: PropertyValue<"fontSize">;
};```
1reaction
berkaeycommented, Oct 17, 2021

Same issue here but with objects,

type TypographyToken = {
  family: ScaleValue<"font">;
  size: ScaleValue<"fontSizes">;
};
 typography: (value: TypographyToken) => {
      const { family, size } = value;
      return {
        fontFamily: family,
        fontSize: size,
        lineHeight: size,
      };
    },

error looks like this,

Screen Shot 2021-10-17 at 23 04 28

no suggestions either but works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript error when using data/props mounting option #194
Some days I wonder if TS is actually making the DX better or worse, lol. import { mount } from '@vue/test-utils' const Layout...
Read more >
Typescript error when using array.map in a function
An array and a function are not compatible types, so you get a type error. I think you meant to do this: const...
Read more >
TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >
typescript-cheatsheet - GitHub Pages
A set of TypeScript related notes used for quick reference. The cheatsheet contains references to types, classes, decorators, and many other TypeScript ......
Read more >
Typechecking With PropTypes - React
For some applications, you can use JavaScript extensions like Flow or TypeScript to typecheck your whole application. But even if you don't use...
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