Skip to content

Commit 2a6575c

Browse files
committed
Test:declaration emit of optional parameter props
1 parent 9737389 commit 2a6575c

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//// [declarationEmitParameterProperty.ts]
2+
export class Foo {
3+
constructor(public bar?: string) {
4+
}
5+
}
6+
7+
8+
//// [declarationEmitParameterProperty.js]
9+
"use strict";
10+
exports.__esModule = true;
11+
var Foo = (function () {
12+
function Foo(bar) {
13+
this.bar = bar;
14+
}
15+
return Foo;
16+
}());
17+
exports.Foo = Foo;
18+
19+
20+
//// [declarationEmitParameterProperty.d.ts]
21+
export declare class Foo {
22+
bar: string | undefined;
23+
constructor(bar?: string | undefined);
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/compiler/declarationEmitParameterProperty.ts ===
2+
export class Foo {
3+
>Foo : Symbol(Foo, Decl(declarationEmitParameterProperty.ts, 0, 0))
4+
5+
constructor(public bar?: string) {
6+
>bar : Symbol(Foo.bar, Decl(declarationEmitParameterProperty.ts, 1, 14))
7+
}
8+
}
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/compiler/declarationEmitParameterProperty.ts ===
2+
export class Foo {
3+
>Foo : Foo
4+
5+
constructor(public bar?: string) {
6+
>bar : string | undefined
7+
}
8+
}
9+

tests/baselines/reference/optionalMethods.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ interface Foo {
131131
}
132132
declare function test1(x: Foo): void;
133133
declare class Bar {
134-
d: number;
134+
d: number | undefined;
135135
e: number;
136136
a: number;
137137
b?: number;
138138
c?: number | undefined;
139-
constructor(d?: number, e?: number);
139+
constructor(d?: number | undefined, e?: number);
140140
f(): number;
141141
g?(): number;
142142
h?(): number;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @strictNullChecks: true
2+
// @declaration: true
3+
export class Foo {
4+
constructor(public bar?: string) {
5+
}
6+
}

0 commit comments

Comments
 (0)