Skip to content

Commit ed7b61c

Browse files
concavelenzcopybara-github
authored andcommitted
Remove support for goog.defineClass in favor of ES Class syntax or traditional ES5 style classes.
PiperOrigin-RevId: 722803069
1 parent 81b17b7 commit ed7b61c

18 files changed

+16
-1859
lines changed

src/com/google/javascript/jscomp/CheckJSDoc.java

+3-25
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,7 @@ private void validateTypedefs(Node n, JSDocInfo info) {
227227
return;
228228
}
229229
Node lvalue = NodeUtil.isNameDeclaration(n) || n.isAssign() ? n.getFirstChild() : n;
230-
// Static properties for goog.defineClass are rewritten to qualified names before typechecking
231-
// runs and are valid as @typedefs.
232-
if (!lvalue.isQualifiedName() && !isGoogDefineClassStatic(lvalue)) {
230+
if (!lvalue.isQualifiedName()) {
233231
reportMisplaced(
234232
n,
235233
"typedef",
@@ -242,14 +240,6 @@ private void validateTypedefs(Node n, JSDocInfo info) {
242240
}
243241
}
244242

245-
/** Whether this is a property in this object: {@code goog.defineClass(superClass, {statics: {} */
246-
private boolean isGoogDefineClassStatic(Node n) {
247-
return n.isStringKey()
248-
&& n.getParent().isObjectLit()
249-
&& n.getGrandparent().isStringKey()
250-
&& n.getGrandparent().getString().equals("statics");
251-
}
252-
253243
private void validateTemplates(Node n, JSDocInfo info) {
254244
if (info != null
255245
&& !info.getTemplateTypeNames().isEmpty()
@@ -286,13 +276,6 @@ && getFunctionDecl(n) == null) {
286276
return n.getLastChild();
287277
}
288278

289-
if (n.isStringKey()
290-
&& n.getGrandparent() != null
291-
&& ClosureRewriteClass.isGoogDefineClass(n.getGrandparent())
292-
&& n.getFirstChild().isFunction()) {
293-
return n.getFirstChild();
294-
}
295-
296279
if (n.isGetterDef() || n.isSetterDef()) {
297280
return n.getFirstChild();
298281
}
@@ -389,13 +372,8 @@ private void validateAbstractJsDoc(Node n, JSDocInfo info) {
389372
return;
390373
}
391374

392-
// TODO(b/124020008): Delete this case when `goog.defineClass` is dropped.
393-
boolean isGoogDefineClassConstructor =
394-
n.getParent().isObjectLit()
395-
&& (n.isMemberFunctionDef() || n.isStringKey())
396-
&& "constructor".equals(n.getString());
397-
if (NodeUtil.isEs6ConstructorMemberFunctionDef(n) || isGoogDefineClassConstructor) {
398-
// @abstract annotation on an ES6 or goog.defineClass constructor
375+
if (NodeUtil.isEs6ConstructorMemberFunctionDef(n)) {
376+
// @abstract annotation on an ES6 constructor
399377
report(n, MISPLACED_ANNOTATION, "@abstract", "constructors cannot be abstract");
400378
return;
401379
}

src/com/google/javascript/jscomp/ClosureCodingConvention.java

-7
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ public void applySubclassRelationship(
136136
return null;
137137
}
138138

139-
private static final QualifiedName GOOG_DEFINECLASS = QualifiedName.of("goog.defineClass");
140-
141-
@Override
142-
public boolean isClassFactoryCall(Node callNode) {
143-
return GOOG_DEFINECLASS.matches(callNode.getFirstChild());
144-
}
145-
146139
/**
147140
* Determines whether the given node is a class-defining name, like "inherits" or "mixin."
148141
*

0 commit comments

Comments
 (0)