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.

Warn when enumerating static properties #121

Open
@DavidSouther

Description

@DavidSouther

In Typescript, I can have a static class property:

class Foo {
  static module = {name: "Foo"};
}

Typescript happily compiles this to

class Foo {
}
Foo.module = { name: "Foo" };

(Static properties aren't valid ES2015: http://www.ecma-international.org/ecma-262/6.0/#sec-class-definitions)

Then, I do this weird thing:

angular.module('myModule', ([Foo, Bar].map(_ => _.module.name))

Where I map over all the classes I intend to instantiate, and prepare their modules.

JSCompiler then helpfully minimizes all this to

angular.a("myModule",[function(){},function(){}].map(function(a){return a.a.name}));

Happily throwing away all the unused properties!

I can add exports:

class Foo {
  /** @export */
  static module = {name: "Foo"};
}

Which Typescript puts in a sane place:

class Foo {
}
/** @export */
Foo.module = { name: "Foo" };

Which JSCompiler ignores.

angular.a("myModule",[function(){},function(){}].map(function(a){return a.a.name}));

I can get away with using the fully qualified form:

angular.module('myModule', [Foo.module.name, Bar.module.name]);

Becomes

angular.a("myModule",["Foo","Bar"]);

Please emit a warning in the property enumeration case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions