open-wc / custom-elements-manifest

Custom Elements Manifest is a file format that describes custom elements in your project.
https://custom-elements-manifest.open-wc.org/
226 stars 37 forks source link

Wrong parse Object from AST #239

Closed next-juanantoniogomez closed 1 month ago

next-juanantoniogomez commented 4 months ago

Checklist

Expected behavior

I have a Lit component (no Typescript) and the constructor assigns a default value to a property. If the value is an object, it is parsed as String instead of Object:

  constructor() {
    super();

    // In the manifest, 'default' value should be "{ foo: 'bar' }" (JSON-stringified),
    // not "{\n        foo: 'bar'\n    }"
    this.foo = {
        foo: 'bar'
    };
  }
"members": [
  {
    "kind": "method",
    "name": "myMethod"
  },
  {
    "kind": "field",
    "name": "foo",
    "privacy": "public",
    "type": {
      "text": "object"
    },
    "description": "Foo value",
    "default": "{\n        foo: 'bar'\n    }",
    "attribute": "foo"
  }
],
"attributes": [
  {
    "name": "foo",
    "type": {
      "text": "object"
    },
    "description": "Foo value",
    "default": "{\n        foo: 'bar'\n    }",
    "fieldName": "foo"
  }
],

In the AST explorer, the object appears as ObjectLiteralExpression, so it could be proccessed as Object.

thepassle commented 1 month ago

this should be fixed in 0.10.1