Skip to content

Feature: resolve default values #21

@fgeierst

Description

@fgeierst

It would be helpful, if the type parser could also resolve default values of properties.

StencilJS 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
  render() {
	  return (
		<div class={this.position}>
		  Hello World
		</div>
	  );
  }
}
// custom-elements.json
          {
            "kind": "field",
            "name": "position",
            "type": {
              "text": "Position"
            },
            "parsedType": {
              "text": "'left' | 'right'"
            },
            "default": "'left'", // 2. this information is currently not provided
          },

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