Skip to content

TypeError: Cannot read properties of undefined (reading 'kind') #304

@web-padawan

Description

@web-padawan

Checklist

Can be reproduced with the branch: https://github.com/vaadin/web-components/tree/proto/cem-analyzer

Running cem analyze for certain Vaadin web components packages (specifically, dashboard) throws:

$ cem analyze --globs "packages/dashboard/src/*.js"  --litelement --dev
[INITIALIZE PLUGINS]
[COLLECT PHASE]:  packages/dashboard/src/keyboard-controller.js
[COLLECT PHASE]:  packages/dashboard/src/vaadin-dashboard-button.js
[COLLECT PHASE]:  packages/dashboard/src/vaadin-dashboard-helpers.js
[COLLECT PHASE]:  packages/dashboard/src/vaadin-dashboard-item-mixin.js
[COLLECT PHASE]:  packages/dashboard/src/vaadin-dashboard-layout-mixin.js
[COLLECT PHASE]:  packages/dashboard/src/vaadin-dashboard-layout.js
[COLLECT PHASE]:  packages/dashboard/src/vaadin-dashboard-section.js
[COLLECT PHASE]:  packages/dashboard/src/vaadin-dashboard-widget.js
[COLLECT PHASE]:  packages/dashboard/src/vaadin-dashboard.js
[COLLECT PHASE]:  packages/dashboard/src/widget-reorder-controller.js
[COLLECT PHASE]:  packages/dashboard/src/widget-resize-controller.js
[ANALYZE PHASE]:  packages/dashboard/src/keyboard-controller.js
[MODULE LINK PHASE]:  packages/dashboard/src/keyboard-controller.js
[ANALYZE PHASE]:  packages/dashboard/src/vaadin-dashboard-button.js
[MODULE LINK PHASE]:  packages/dashboard/src/vaadin-dashboard-button.js
[ANALYZE PHASE]:  packages/dashboard/src/vaadin-dashboard-helpers.js
[MODULE LINK PHASE]:  packages/dashboard/src/vaadin-dashboard-helpers.js
[ANALYZE PHASE]:  packages/dashboard/src/vaadin-dashboard-item-mixin.js
[MODULE LINK PHASE]:  packages/dashboard/src/vaadin-dashboard-item-mixin.js
[ANALYZE PHASE]:  packages/dashboard/src/vaadin-dashboard-layout-mixin.js
[MODULE LINK PHASE]:  packages/dashboard/src/vaadin-dashboard-layout-mixin.js
[ANALYZE PHASE]:  packages/dashboard/src/vaadin-dashboard-layout.js
[MODULE LINK PHASE]:  packages/dashboard/src/vaadin-dashboard-layout.js
[ANALYZE PHASE]:  packages/dashboard/src/vaadin-dashboard-section.js
[MODULE LINK PHASE]:  packages/dashboard/src/vaadin-dashboard-section.js
[ANALYZE PHASE]:  packages/dashboard/src/vaadin-dashboard-widget.js
[MODULE LINK PHASE]:  packages/dashboard/src/vaadin-dashboard-widget.js
[ANALYZE PHASE]:  packages/dashboard/src/vaadin-dashboard.js
file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/utils/index.js:69
    throw new Error(`\n\n[${name ?? 'unnamed-plugin'}]: ${errorMessage}\n\n ${e.stack}\n`);
          ^

Error:

[CORE - CLASSES]: Looks like you've hit an error in the core library. Please try to create a minimal reproduction at https://custom-elements-manifest.netlify.com and create an issue at: https://github.com/open-wc/custom-elements-manifest/issues

 TypeError: Cannot read properties of undefined (reading 'kind')
    at Object.isCallExpression (/Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typescript.js:26750:17)
    at file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js:189:19
    at Array.forEach (<anonymous>)
    at file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js:180:20
    at Array.forEach (<anonymous>)
    at handleHeritage (file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js:176:26)
    at createClass (file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:163:19)
    at analyzePhase (file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js:14:25)
    at file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/create.js:111:23
    at withErrorHandling (file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/utils/index.js:60:5)
    at withErrorHandling (file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/utils/index.js:69:11)
    at file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/create.js:110:7
    at Array.forEach (<anonymous>)
    at visitNode (file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/create.js:109:19)
    at visitNodes (/Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typescript.js:28321:24)
    at forEachChildInSourceFile (/Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typescript.js:28964:18)
    at Object.forEachChild (/Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typescript.js:28406:37)
    at visitNode (file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/create.js:115:8)
    at analyze (file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/create.js:106:3)
    at file:///Users/serhii/vaadin/web-components/node_modules/@custom-elements-manifest/analyzer/src/create.js:57:5

Note

Seems like this code I18nMixin(getDefaultI18n() part could be relevant - we pass additional argument to the mixin.
Moving getDefaultI18n() call to a constant seems to help but then it is incorrectly treated as a superclass:

          "superclass": {
            "name": "DEFAULT_I18N",
            "module": "packages/dashboard/src/vaadin-dashboard.js"
          },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions