Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

using clutz with a goog.module #1258

@ribrdb

Description

@ribrdb

I'm posting this here since clutz is archived.
I'm trying to use clutz with a goog.module. No matter what I do though, it seems to output 'module$exports' types for everything that it requires, even if they come from a goog.provide.

I've tried creating a depgraph listing the provides, but it doesn't seem to make any difference.

goog.module('mymodule');
const TestAllTypes = goog.require('proto.test.TestAllTypes');

/** @const */
exports.TestAllTypes = TestAllTypes;
[
  [ "nonroots", [
    [ "foobar.js", [
      [ "provides", [
          "foobar.js",
          "proto.test.TestAllTypes"
      ]]
    ]]
  ]],
  [ "roots", [
      [ "bazel-out/darwin-fastbuild/bin/test/mymodule.js", []]
  ]]
]

clutz --partialInput -o mymodule.clutz.d.ts --depgraphs mymodule.depgraph --path/to/mymodule.js path/to/partial_goog_base.js

results in

//!! generated by clutz.
// Generated from bazel-out/darwin-fastbuild/bin/test/mymodule.js
declare namespace ಠ_ಠ.clutz.module$exports$mymodule {
  export import TestAllTypes = ಠ_ಠ.clutz.module$exports$proto$test$TestAllTypes ;
}
declare module 'goog:mymodule' {
  import mymodule = ಠ_ಠ.clutz.module$exports$mymodule;
  export = mymodule;
}

I'm expecting that to be ಠ_ಠ.clutz.proto.test.TestAllTypes.
For example, that declarations file has:

declare namespace ಠ_ಠ.clutz.proto.test {
  /**
   * Generated by JsPbCodeGenerator.
   */
  class TestAllTypes extends ಠ_ಠ.clutz.jspb.Message {
...
}
declare module 'goog:proto.test.TestAllTypes' {
  import TestAllTypes = ಠ_ಠ.clutz.proto.test.TestAllTypes;
  export default TestAllTypes;
}

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