Giter Site home page Giter Site logo

Comments (5)

thepassle avatar thepassle commented on June 22, 2024 3

This was corrected in @custom-elements-manifest/analyzer v0.4.7 👍

from custom-elements-manifest.

thepassle avatar thepassle commented on June 22, 2024 1

I've ran into the situation myself a couple of times as well, where I need to find a class that is exported as default. I do think this is currently a limitation of the schema, and we should improve on this

from custom-elements-manifest.

Matsuuu avatar Matsuuu commented on June 22, 2024

Example case:

https://custom-elements-manifest.netlify.app/?source=CmV4cG9ydCBkZWZhdWx0IGNsYXNzIE15RWxlbWVudCBleHRlbmRzIEhUTUxFbGVtZW50IHt9CgpleHBvcnQgY2xhc3MgTXlFeHRlbmRpbmdFbGVtZW50IGV4dGVuZHMgTXlFbGVtZW50IHt9CmN1c3RvbUVsZW1lbnRzLmRlZmluZSgibXktZXh0ZW5kaW5nLWVsZW1lbnQiLCBNeUV4dGVuZGluZ0VsZW1lbnQpOw%3D%3D&library=vanilla

If we have a MyElement class we want to extend our element from, and then we want to backtrack from MyExtendingElement's "superclass.name" to find the declarations of it, we can't find it with the current information, as the name "MyElement" is not present in the declaration at all.

"declarations": [
        {
          "kind": "class",
          "description": "",
          "name": "default",
          "superclass": {
            "name": "HTMLElement"
          },
          "customElement": true
        },
        {
          "kind": "class",
          "description": "",
          "name": "MyExtendingElement",
          "superclass": {
            "name": "MyElement",
            "module": "src/my-element.js"
          },
          "tagName": "my-extending-element",
          "customElement": true
        }
      ],

from custom-elements-manifest.

justinfagnani avatar justinfagnani commented on June 22, 2024

The way this should work is the same for any export that renames the item: the export has a name that's independent of the declaration name.

export default class MyElement {}

should result in an export named "default" and a reference to a class declaration named "MyElement".

Same with a rename:

class MyElementImpl {}
export {MyElementImpl as MyElement}

should result in an export named "MyElement" and a reference to a class declaration named "MyElementImpl".

From the playground it looks like the analyzer is getting this wrong.

This:

      "declarations": [
        {
          "kind": "class",
          "description": "",
          "name": "default",
          "superclass": {
            "name": "HTMLElement"
          },
          "customElement": true
        },

Should be:

      "declarations": [
        {
          "kind": "class",
          "description": "",
          "name": "MyElement",
          "superclass": {
            "name": "HTMLElement"
          },
          "customElement": true
        },

iow, a declaration should never have the name "default", unless someone actually named a class/function/variable that.

from custom-elements-manifest.

justinfagnani avatar justinfagnani commented on June 22, 2024

Looks like this is being fixed in the Open WC analyzer. Closing here.

from custom-elements-manifest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.