aws/jsii-rosetta

Processing jsii assembly results in "Cannot read properties of undefined (reading 'kind')"

gadams999 opened this issue · 1 comments

Hi,

I'm creating a new CdklabsConstructLibrary from cdklabs-projen-project-types. I can correctly compile the jsii, and docgen works correctly, but when the rosetta:extract takes place I am getting this error:

👾 rosetta:extract | yarn --silent jsii-rosetta extract --strict
[jsii-rosetta] [ERROR] Cannot read properties of undefined (reading 'kind')
[jsii-rosetta] [ERROR] TypeError: Cannot read properties of undefined (reading 'kind')
    at sidelineImports (cdk-aws-iot-thing-certificate-policy/node_modules/jsii-rosetta/lib/fixtures.js:163:54)
    at loadAndSubFixture (cdk-aws-iot-thing-certificate-policy/node_modules/jsii-rosetta/lib/fixtures.js:93:37)
    at fixturize (cdk-aws-iot-thing-certificate-policy/node_modules/jsii-rosetta/lib/fixtures.js:39:18)
    at cdk-aws-iot-thing-certificate-policy/node_modules/jsii-rosetta/lib/jsii/assemblies.js:174:41
    at async Promise.all (index 0)
    at async extractSnippets (cdk-aws-iot-thing-certificate-policy/node_modules/jsii-rosetta/lib/commands/extract.js:30:31)
    at async cdk-aws-iot-thing-certificate-policy/node_modules/jsii-rosetta/lib/main.js:246:15

There are kind properties in the .jsii file, such as this:

    "cdk-aws-iot-thing-certificate-policy.IotThingCertificatePolicyProps": {
      "assembly": "cdk-aws-iot-thing-certificate-policy",
      "datatype": true,
      "docs": {
        "custom": {
          "summary": "text of the Props"
        },
        "stability": "experimental"
      },
      "fqn": "cdk-aws-iot-thing-certificate-policy.IotThingCertificatePolicyProps",
      "kind": "interface",
      "locationInModule": {
        "filename": "src/index.ts",
        "line": 30
      },

With the specific kinds of interface, class, and array.

My .projenrc.ts file contains the following dependencies, and I have upgraded to the latest versions of all modules:

  deps: ["cdk-nag", "handlebars"],
  devDeps: ["cdklabs-projen-project-types"],
  peerDeps: ["aws-cdk-lib"],
  bundledDeps: ["handlebars"],
  jsiiVersion: "~5.4.0",

The package.json contains:

    "jsii": "~5.4.0",
    "jsii-diff": "^1.97.0",
    "jsii-docgen": "^10.4.1",
    "jsii-pacmak": "^1.97.0",
    "jsii-rosetta": "^5.4.0",

And yarn.lock has the following for jsii-rosetta:

jsii-rosetta@^5.4.0:
  version "5.4.0"
  resolved "https://registry.yarnpkg.com/jsii-rosetta/-/jsii-rosetta-5.4.0.tgz#92af7c0a1e56cf5fffed8662a5d24d7c017f9283"
  integrity sha512-9d4uWRSy80jbi5hClHxP3S7EHi91zKCBWw9d0bup4waMnLYkmy4csNHms40OX83L1hPY/QZXdWjwPymPatV8Ag==
  dependencies:
    "@jsii/check-node" "1.96.0"
    "@jsii/spec" "^1.96.0"
    "@xmldom/xmldom" "^0.8.10"
    chalk "^4"
    commonmark "^0.31.0"
    fast-glob "^3.3.2"
    jsii "~5.4.0"
    semver "^7.6.0"
    semver-intersect "^1.5.0"
    stream-json "^1.8.0"
    typescript "~5.4"
    workerpool "^6.5.1"
    yargs "^17.7.2"

Looking for guidance on how to resolve the issue and get the other language documentation generated.

Turns out this happens when the export is annotated with a docstring:

/**
 * JSDoc
 */
export const foo = "bar";