also looking at this
fix(extractor): keep the heritage clause of an anonymous default class
#3124
2 files
+103
-1
| @@ -2607,7 +2607,16 @@ function scanDeclarationsInternal(_source: string, _filename: string, _keepComme | ||
| 2607 | 2607 | pos += 5 // skip 'class' |
| 2608 | 2608 | skipWhitespaceAndComments() |
| 2609 | 2609 | |
| 2610 | const name = readIdent() || 'AnonymousClass' | |
| 2610 | // `export default class extends Base {}` has no name: `extends`, or | |
| 2611 | // `implements` before a type, begins its heritage clause, as TypeScript | |
| 2612 | // reads it. Such a class gets a helper name the file does not use, as a | |
| 2613 | // default-exported expression does. | |
| 2614 | const isAnonymous = isDefault && (matchWord('extends') || (matchWord('implements') && isIdentStart(peekAfterWord('implements')))) | |
| 2615 | let name = isAnonymous ? '' : (readIdent() || 'AnonymousClass') | |
| 2616 | if (!name) { | |
| 2617 | name = '__dtsx_default_class__' | |
| 2618 | for (let suffix = 1; source.includes(name); suffix++) name = `__dtsx_default_class_${suffix}__` | |
| 2619 | } | |
| 2611 | 2620 | skipWhitespaceAndComments() |
| 2612 | 2621 | |
| 2613 | 2622 | const generics = extractGenerics() |