Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: [CORE - LIT-STATIC-PROPERTIES]: Looks like you've hit an error in the core library. #163

Closed
domoskanonos opened this issue Apr 12, 2022 · 12 comments

Comments

@domoskanonos
Copy link

NPM command: custom-elements-manifest analyze --outdir public/ --litelement --dev

with node version 14.17.0 everything works fine, version 16.14.2 broken with error:

TypeError: Cannot read properties of undefined (reading 'push')
at mapClassMember (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:242:27)
at file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:211:35
at Array.forEach ()
at visitNode (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:211:12)
at visitNodes (C:\machineroom\git\ui-blueprint-webcomponent\blueprint-frontend\node_modules@custom-elements-manifest\analyzer\node_modules\typescript\lib\typescript.js:29004:30)
at Object.forEachChild (C:\machineroom\git\ui-blueprint-webcomponent\blueprint-frontend\node_modules@custom-elements-manifest\analyzer\node_modules\typescript\lib\typescript.js:29316:21)
at visitNode (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:216:8)
at getDefaultValuesFromConstructorVisitor (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:200:3)
at analyzePhase (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js:75:11)
at file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/create.js:104:23

at withErrorHandling (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/utils/index.js:67:11)
at file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/create.js:103:7
at Array.forEach (<anonymous>)
at visitNode (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/create.js:102:19)
at visitNodes (C:\machineroom\git\ui-blueprint-webcomponent\blueprint-frontend\node_modules\@custom-elements-manifest\analyzer\node_modules\typescript\lib\typescript.js:29004:30)
at Object.forEachChild (C:\machineroom\git\ui-blueprint-webcomponent\blueprint-frontend\node_modules\@custom-elements-manifest\analyzer\node_modules\typescript\lib\typescript.js:29241:24)
at visitNode (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/create.js:108:8)
at visitNode (C:\machineroom\git\ui-blueprint-webcomponent\blueprint-frontend\node_modules\@custom-elements-manifest\analyzer\node_modules\typescript\lib\typescript.js:28995:24)
at Object.forEachChild (C:\machineroom\git\ui-blueprint-webcomponent\blueprint-frontend\node_modules\@custom-elements-manifest\analyzer\node_modules\typescript\lib\typescript.js:29125:21)
at visitNode (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/create.js:108:8)
@thepassle
Copy link
Member

thepassle commented Apr 12, 2022

could you post some reproduction code please? :)

Seems like currClass

getDefaultValuesFromConstructorVisitor(node, currClass, context);

which we get from here

const currClass = moduleDoc?.declarations?.find(declaration => declaration.name === className);

is not found for some reason, gotta figure out why, but need some reproduction code/playground url to be able to investigate

Not sure why different node versions would have anything to do with it though, we don't really do anything exotic in that regard.

@domoskanonos
Copy link
Author

domoskanonos commented Apr 12, 2022

import {LitElement, TemplateResult, html} from "lit";
import {customElement, property} from "lit/decorators.js";
import {environment} from "../environments/environment";
import {OpenidService} from "../service/openid-service";

@CustomElement("si-ui-blueprint-webcomponent")
export class SiUiBlueprintWebcomponent extends LitElement {

@property({type: String})
status: string = "success";

public render(): TemplateResult {
    return html`Something to render `;
}

private login(): void {
    
}

private newListItem(text: string) {
    return html`
       something`;
}

}

@domoskanonos
Copy link
Author

lit version is: "lit": "2.2.1",

@thepassle
Copy link
Member

Im not able to reproduce locally or in the playground
image

Do note that you're importing

import {customElement, property} from "lit/decorators.js";

but using it with a capital:

@CustomElement("si-ui-blueprint-webcomponent")

@domoskanonos
Copy link
Author

@CustomElement -> git automatically capitalized it

@domoskanonos
Copy link
Author

in my code it's lowercase "c"

@domoskanonos
Copy link
Author

ok i will try to find out where the problem is and i will report here. If i remove "--litElement" flag it works...

@domoskanonos
Copy link
Author

exact environment : node: v16.14.2, npm: 8.5.0

@valentindiehl
Copy link

@domoskanonos Have you found a solution for this? I'm having the same issue, but I'm trying for days to find the source since it randomly appeared without really changing or updating anything.

As soon as I find a minimal example without 300 lines of code, I'll post it here.

@valentindiehl
Copy link

To add to this: The error already happens when running "npm install", not even while transpiling with run/build

@DeepakJY97SF
Copy link

DeepakJY97SF commented Sep 28, 2022

I fixed this issue in the createClass.js by checking for classTemplate.members existence and initialize it with empty array if undefined

old:

  if (!existingMember) {
    if (hasIgnoreJSDoc(statement)) return;
    if (isBindCall(statement)) return;

    existingMember = {
      kind: 'field',
      name: expression?.left?.name?.getText(),
    }
    classTemplate.members.push(existingMember);
  }

new:

  if (!existingMember) {
    if (hasIgnoreJSDoc(statement)) return;
    if (isBindCall(statement)) return;

    existingMember = {
      kind: 'field',
      name: expression?.left?.name?.getText(),
    }
    if(!classTemplate.members){
      classTemplate.members = [];
    }
    classTemplate.members.push(existingMember);
  }

I tried to push a fix branch to create a pullrequest, but I don't have the rights

thepassle added a commit that referenced this issue Oct 9, 2022
@KameronKales
Copy link

KameronKales commented Oct 21, 2022

I had this issue (independent of which node version I was running, i tried 14 and 16).

Version: "@custom-elements-manifest/analyzer": "^0.6.4"

I was able to fix by being verify specific about what code to include via --glob.

For a project im working on

This works:

cem analyze --litelement --globs packages/*/* --exclude packages/*/dist

This does not

cem analyze --litelement --exclude packages/*/dist

and this does not

cem analyze --litelement --globs packages/*/*

Obviously YMMV but changing this command got me up and running again. Im assuming there is some code in my project that is causing the issue and I should have been using globs all along

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants