Repository navigation
Do not emit code for @extends tags in JS. - #29244
Conversation
71783ba to
162b6f0
Compare
80cca24 to
fd7a197
Compare
|
Martin Probst (@mprobst) you'll find the tests easier to write/baseline if you add a // @outDir: ./out
// @allowJs: true
// @filename: extends.js
/** @extends {SuperClass} */
class SubClass {}should work. |
|
Wesley Wigham (@weswigham) thanks! I'll take a look at that tomorrow. I don't understand my test failure, locally |
|
I would guess it's failing because your input file, |
|
You definitely want to write a |
When transpiling JavaScript, TS3.1+ emits `@extends` tags as code. E.g.
/** @extends {SuperClass} */
class SubClass {}
Causes an ES5 emit that references SuperClass:
/**
* @extends {SomeBase}
*/
var SubClass = /** @Class */ (function (_super) {
__extends(SubClass, _super);
function SubClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
return SubClass;
}(SomeBase));
Note the literal references to `SomeBase`.
This appears to be an accidental effect of 0f55566. It refactored
`getEffectiveBaseTypeNode` for type checking, but missed an instance
where it is also used for emit logic. This change fixes the problem by
specifically getting the heritage clauses directly off the AST.
Change-Id: I3128a757e5924e2528c61230a90ac13650852542
fd7a197 to
3381e72
Compare
|
💡 For context, I was looking for tests that used I've moved to a compiler test case, that's indeed much simpler. |
This fixes a similar problem as microsoft#29244 where JSDoc `@extends`
When transpiling JavaScript, TS3.1+ emits
@extendstags as code. E.g.Causes an ES5 emit that references SuperClass:
Note the literal references to
SomeBase.This appears to be an accidental effect of
0f55566. It refactored
getEffectiveBaseTypeNodefor type checking, but missed an instancewhere it is also used for emit logic. This change fixes the problem by
specifically getting the heritage clauses directly off the AST.