Skip to content

Commit dac7fdb

Browse files
committed
fix(44273): preserves 'override' modifier in JavaScript output
1 parent 5fde871 commit dac7fdb

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ namespace ts {
368368
case SyntaxKind.PrivateKeyword:
369369
case SyntaxKind.ProtectedKeyword:
370370
case SyntaxKind.AbstractKeyword:
371+
case SyntaxKind.OverrideKeyword:
371372
case SyntaxKind.ConstKeyword:
372373
case SyntaxKind.DeclareKeyword:
373374
case SyntaxKind.ReadonlyKeyword:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [override16.ts]
2+
class A {
3+
foo?: string;
4+
}
5+
6+
class B extends A {
7+
override foo = "string";
8+
}
9+
10+
11+
//// [override16.js]
12+
class A {
13+
foo;
14+
}
15+
class B extends A {
16+
foo = "string";
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/conformance/override/override16.ts ===
2+
class A {
3+
>A : Symbol(A, Decl(override16.ts, 0, 0))
4+
5+
foo?: string;
6+
>foo : Symbol(A.foo, Decl(override16.ts, 0, 9))
7+
}
8+
9+
class B extends A {
10+
>B : Symbol(B, Decl(override16.ts, 2, 1))
11+
>A : Symbol(A, Decl(override16.ts, 0, 0))
12+
13+
override foo = "string";
14+
>foo : Symbol(B.foo, Decl(override16.ts, 4, 19))
15+
}
16+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/conformance/override/override16.ts ===
2+
class A {
3+
>A : A
4+
5+
foo?: string;
6+
>foo : string
7+
}
8+
9+
class B extends A {
10+
>B : B
11+
>A : A
12+
13+
override foo = "string";
14+
>foo : string
15+
>"string" : "string"
16+
}
17+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @target: esnext
2+
// @noImplicitOverride: true
3+
4+
class A {
5+
foo?: string;
6+
}
7+
8+
class B extends A {
9+
override foo = "string";
10+
}

0 commit comments

Comments
 (0)