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

Incorrect type definition in Config.d.ts #832

Closed
yunhao opened this issue Jun 18, 2022 · 1 comment
Closed

Incorrect type definition in Config.d.ts #832

yunhao opened this issue Jun 18, 2022 · 1 comment

Comments

@yunhao
Copy link
Contributor

yunhao commented Jun 18, 2022

What happened

When using the NPM Module and Typescript to write a build script, the following code compiles successfully. It passes TypeScript's type system.

StyleDictionary.extend({
  transformGroup: {
    "custom/ios-swift": {
      transforms: [
        "category/normalize",
        'attribute/cti',
        // ...
      ]
    }
  },
  platforms: {
    // ...
  }
})

However, when you run the code, you will see an error:

to_ret.transforms = transforms.map(function(name) {
                                 ^

TypeError: transforms.map is not a function

Expect

After looking at the source code, I found that the correct code should be:

StyleDictionary.extend({
  transformGroup: {
    "custom/ios-swift": [
      "category/normalize",
      'attribute/cti',
      // ...
    ]
  },
  platforms: {
    // ...
  }
})

Unfortunately, the code will not compile because of type mismatches. However, if you make some changes to make the code compilable (e.g. using any type) and then run it, it will work fine.

How to fix it

transformGroup?: Record<string, TransformGroup>;

I think we should change this line of code to:

transformGroup?: Record<string, TransformGroup['transform']>;
@jorenbroekema
Copy link
Collaborator

jorenbroekema commented Mar 27, 2024

Fixed in v4 branch

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

No branches or pull requests

2 participants