()
| 139 | } |
| 140 | |
| 141 | function pushBody() { |
| 142 | const classBodyPaths: any[] = path.get("body.body"); |
| 143 | |
| 144 | for (const path of classBodyPaths) { |
| 145 | const node = path.node; |
| 146 | |
| 147 | if (path.isClassProperty() || path.isClassPrivateProperty()) { |
| 148 | throw path.buildCodeFrameError("Missing class properties transform."); |
| 149 | } |
| 150 | |
| 151 | if (path.isStaticBlock()) { |
| 152 | // @babel/plugin-transform-class-static-block alone is not enough: it |
| 153 | // turns static blocks into static fields so we also need class-properties. |
| 154 | throw path.buildCodeFrameError( |
| 155 | "Missing class static block transform. " + |
| 156 | 'Please make sure that "@babel/plugin-transform-class-static-block" ' + |
| 157 | 'and "@babel/plugin-transform-class-properties" come *before* ' + |
| 158 | '"@babel/plugin-transform-classes".', |
| 159 | ); |
| 160 | } |
| 161 | |
| 162 | if (path.isClassPrivateMethod()) { |
| 163 | throw path.buildCodeFrameError( |
| 164 | "Missing class private methods transform.", |
| 165 | ); |
| 166 | } |
| 167 | |
| 168 | if (path.isClassAccessorProperty()) { |
| 169 | // @babel/plugin-proposal-decorators alone is not enough: it turns |
| 170 | // accessor properties into private fields so we also need class-properties. |
| 171 | throw path.buildCodeFrameError( |
| 172 | "Class accessor properties are not compiled by this transform. " + |
| 173 | 'Please make sure that "@babel/plugin-proposal-decorators" and ' + |
| 174 | '"@babel/plugin-transform-class-properties" come *before* ' + |
| 175 | '"@babel/plugin-transform-classes".', |
| 176 | ); |
| 177 | } |
| 178 | |
| 179 | if (node.decorators) { |
| 180 | throw path.buildCodeFrameError( |
| 181 | "Method has decorators, put the decorator plugin before the classes one.", |
| 182 | ); |
| 183 | } |
| 184 | |
| 185 | if (t.isClassMethod(node)) { |
| 186 | const isConstructor = node.kind === "constructor"; |
| 187 | |
| 188 | const replaceSupers = new ReplaceSupers({ |
| 189 | methodPath: path, |
| 190 | objectRef: classState.classRef, |
| 191 | superRef: classState.superName, |
| 192 | constantSuper: assumptions.constantSuper, |
| 193 | file: file, |
| 194 | refToPreserve: classState.classRef, |
| 195 | }); |
| 196 | |
| 197 | replaceSupers.replace(); |
| 198 |
no test coverage detected