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

bug: docs-json output target does not always expand values for a prop type correctly #6149

Open
3 tasks done
brandongregoryscott opened this issue Feb 6, 2025 · 0 comments
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted

Comments

@brandongregoryscott
Copy link
Contributor

Prerequisites

Stencil Version

4.25.3

Current Behavior

There are certain conditions that can cause the values array for a component prop to be generated incorrectly, i.e. not expanding types and a mangled string split of values.

For example, I am getting an array of values like this:

"values": [
  {
    "type": "ColorName"
  },
  {
    "type": "AllowedColors<\"Lavender-100\""
  },
  {
    "value": "Lavender-200",
    "type": "string"
  },
  {
    "value": "Lavender-300",
    "type": "string"
  },
  {
    "value": "Lavender-400",
    "type": "string"
  },
  {
    "value": "Lavender-500",
    "type": "string"
  },
  {
    "value": "Lavender-600",
    "type": "string"
  },
  {
    "value": "Ivy-100",
    "type": "string"
  },
  {
    "value": "Ivy-200",
    "type": "string"
  },
  {
    "value": "Ivy-300",
    "type": "string"
  },
  {
    "value": "Ivy-400",
    "type": "string"
  },
  {
    "value": "Ivy-500",
    "type": "string"
  },
  {
    "value": "Ivy-600",
    "type": "string"
  },
  {
    "value": "Rose-100",
    "type": "string"
  },
  {
    "value": "Rose-200",
    "type": "string"
  },
  {
    "value": "Rose-300",
    "type": "string"
  },
  {
    "value": "Rose-400",
    "type": "string"
  },
  {
    "value": "Rose-500",
    "type": "string"
  },
  {
    "type": "\"Rose-600\">"
  }
],

"type": "AllowedColors<\"Lavender-100\"" and "type": "\"Rose-600\">" are obviously not intended, and ColorName is not expanded.

Expected Behavior

I would expect the underlying values for the type to be expanded, i.e.

"values": [
  {
    "value": "Lavender",
    "type": "string"
  },
  {
    "value": "Ivy",
    "type": "string"
  },
  {
    "value": "Rose",
    "type": "string"
  },
  {
    "value": "Lavender-100",
    "type": "string"
  },
  {
    "value": "Lavender-200",
    "type": "string"
  },
  {
    "value": "Lavender-300",
    "type": "string"
  },
  {
    "value": "Lavender-400",
    "type": "string"
  },
  {
    "value": "Lavender-500",
    "type": "string"
  },
  {
    "value": "Lavender-600",
    "type": "string"
  },
  {
    "value": "Ivy-100",
    "type": "string"
  },
  {
    "value": "Ivy-200",
    "type": "string"
  },
  {
    "value": "Ivy-300",
    "type": "string"
  },
  {
    "value": "Ivy-400",
    "type": "string"
  },
  {
    "value": "Ivy-500",
    "type": "string"
  },
  {
    "value": "Ivy-600",
    "type": "string"
  },
  {
    "value": "Rose-100",
    "type": "string"
  },
  {
    "value": "Rose-200",
    "type": "string"
  },
  {
    "value": "Rose-300",
    "type": "string"
  },
  {
    "value": "Rose-400",
    "type": "string"
  },
  {
    "value": "Rose-500",
    "type": "string"
  },
  {
    "value": "Rose-600",
    "type": "string"
  }
],

System Info

System: node 22.7.0
    Platform: darwin (24.1.0)
   CPU Model: Apple M1 Pro (8 cpus)
    Compiler: /Users/Brandon/stencil-generic-prop-values-issue/node_modules/@stencil/core/compiler/stencil.js
       Build: 1738713818
     Stencil: 4.25.3 🚁
  TypeScript: 5.5.4
      Rollup: 2.56.3
      Parse5: 7.1.2
      jQuery: 4.0.0-pre
      Terser: 5.31.1

Steps to Reproduce

Check the reproduction repo I linked.

  1. Clone the repo
  2. Run npm install
  3. Run npm run build
  4. Inspect the generated docs.json file. Notice the incorrect values array for the color prop.

Play around uncommenting the other variations of types that do not result in the same behavior (you'll need to re-run a build each time)

Code Reproduction URL

https://github.com/brandongregoryscott/stencil-generic-prop-values-issue

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Feb 6, 2025
@christian-bromann christian-bromann added Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted and removed triage labels Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted
Projects
None yet
Development

No branches or pull requests

2 participants