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

Typescript value vs type reference (v4.0.3) #550

Open
jzempel opened this issue Nov 10, 2020 · 1 comment
Open

Typescript value vs type reference (v4.0.3) #550

jzempel opened this issue Nov 10, 2020 · 1 comment
Labels

Comments

@jzempel
Copy link

jzempel commented Nov 10, 2020

  • polished version: 4.0.3
  • JSS-in_CSS library and version: styled-components 4.4.1
  • Any relevant JS library and version: React 16.13.1

Mixin/Helper/Shorthand Usage

Updated code based on v4 breaking changes.

import exponentialSymbols from 'polished/lib/math/presets/exponentialSymbols';

const squareSize = math(`${size} * 2 / sqrt(2)`, exponentialSymbols);

What You Are Seeing

On tsc compile:

Screen Shot 2020-11-10 at 8 33 15 AM

What You Expected To See

No tsc errors with exponentialSymbols import. I think the fix might be as simple as adding typeof to the function definitions in https://unpkg.com/browse/polished@4.0.3/lib/math/presets/exponentialSymbols.d.ts.

declare const exponentialSymbols: {
  symbols: {
    '!': {
      postfix: {
        f: typeof factorial;
        ...
      };
    };
    '^': {
      infix: {
        f: typeof power;
        ...
      };
    };
    sqrt: {
      func: {
        f: typeof sqrt;
        ...
      };
    };
  };
};

Reproduction

Currently working around by inlining the symbols definition for sqrt. See https://github.com/zendeskgarden/react-components/pull/920/files#diff-e8a3ada410dbb11bc3294a80df7fd05ac795d41d99ffdc21e4597c7787fa7991 for details.

@bhough
Copy link
Contributor

bhough commented Nov 21, 2020

@jzempel Thank you for bringing this to our attention. We were missing a TS test for this scenario.

Unfortunately, the library we use for generating types for TS is fairly limited and no longer maintained. We are rewriting 5.0 in TS natively, so this will be addressed then. Apologies for the limitation.

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

No branches or pull requests

2 participants