Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit 74e44ce

Browse files
committed
add super keyword support
1 parent d0867a9 commit 74e44ce

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

openrewrite/src/javascript/parser.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,10 @@ export class JavaScriptParserVisitor {
17601760
)
17611761
}
17621762

1763+
visitSuperKeyword(node: ts.KeywordToken<ts.SyntaxKind.SuperKeyword>) {
1764+
return this.mapIdentifier(node, node.getText());
1765+
}
1766+
17631767
visitNewExpression(node: ts.NewExpression) {
17641768
return new J.NewClass(
17651769
randomId(),
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {connect, disconnect, rewriteRun, rewriteRunWithOptions, typeScript} from '../testHarness';
2+
3+
describe('highlight.js files tests', () => {
4+
beforeAll(() => connect());
5+
afterAll(() => disconnect());
6+
7+
test('twenty/packages/twenty-server/src/modules/messaging/message-import-manager/exceptions/message-import.exception.ts', () => {
8+
rewriteRun(
9+
//language=typescript
10+
typeScript(`
11+
import { CustomException } from 'src/utils/custom-exception';
12+
13+
export class MessageImportException extends CustomException {
14+
code: MessageImportExceptionCode;
15+
constructor(message: string, code: MessageImportExceptionCode) {
16+
super(message, code);
17+
}
18+
}
19+
20+
export enum MessageImportExceptionCode {
21+
UNKNOWN = 'UNKNOWN',
22+
PROVIDER_NOT_SUPPORTED = 'PROVIDER_NOT_SUPPORTED',
23+
MESSAGE_CHANNEL_NOT_FOUND = 'MESSAGE_CHANNEL_NOT_FOUND',
24+
}
25+
`)
26+
);
27+
});
28+
29+
});

openrewrite/test/javascript/parser/class.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,20 @@ describe('class mapping', () => {
265265
);
266266
});
267267

268+
test('class extends expression with constructor', () => {
269+
rewriteRun(
270+
//language=typescript
271+
typeScript(`
272+
class OuterClass extends (class extends Number {
273+
}) {
274+
constructor() {
275+
/*1*/ super /*2*/ () /*3*/;
276+
}
277+
}
278+
`)
279+
);
280+
});
281+
268282
test('class expressions inline', () => {
269283
rewriteRun(
270284
//language=typescript

0 commit comments

Comments
 (0)