8000 Cherry-pick PR #44290 into release-4.3 (#44425) · microsoft/TypeScript@4f7fe4a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f7fe4a

Browse files
TypeScript Bota-tarasyuk
andauthored
Cherry-pick PR #44290 into release-4.3 (#44425)
Component commits: f3bf29a fix(44273): preserves 'override' modifier in JavaScript output Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
1 parent e425f57 commit 4f7fe4a

25 files changed

+574
-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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
}
14+
class B extends A {
15+
constructor() {
16+
super(...arguments);
17+
this.foo = "string";
18+
}
19+
}
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: 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: 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+

0 commit comments

Comments
 (0)
0