Skip to content

Analyzer (Stencil): default values are not resolved #327

@fgeierst

Description

@fgeierst

Checklist

  • Did you run the analyzer with the --dev flag to get more information?
  • Did you create a minimal reproduction in the playground?

Currently, the parser does not resolve default values of properties.

Playground reproduction

Expected behavior
The analyser outputs the default values even if that is derived from somewhere else.

Example

// my-component.tsx
import { Component, Prop, h } from '@stencil/core';

const Position = {
  LEFT: 'left',
  RIGHT: 'right',
} as const;

type Position = (typeof Position)[keyof typeof Position];

@Component({
  tag: 'my-greeting',
  shadow: true
})
export class MyGreeting {
  @Prop() position: Position = Position.LEFT; // 1. default value is set here
}
// custom-elements.json
          {
            "kind": "field",
            "name": "position",
            "type": {
              "text": "Position"
            },
            "parsedType": {
              "text": "'left' | 'right'"
            },
            "default": "'left'", // 2. this information is currently not provided
          },

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions