Typescript value vs type reference (v4.0.3)
-
polishedversion: 4.0.3 -
JSS-in_CSSlibrary 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:
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/[email protected]/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.
@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.