Test:declaration emit of optional parameter props

This commit is contained in:
Nathan Shively-Sanders 2017-06-13 11:50:46 -07:00
parent 433a06d599
commit 5780494ddb
5 changed files with 50 additions and 2 deletions

View File

@ -0,0 +1,24 @@
//// [declarationEmitParameterProperty.ts]
export class Foo {
constructor(public bar?: string) {
}
}
//// [declarationEmitParameterProperty.js]
"use strict";
exports.__esModule = true;
var Foo = (function () {
function Foo(bar) {
this.bar = bar;
}
return Foo;
}());
exports.Foo = Foo;
//// [declarationEmitParameterProperty.d.ts]
export declare class Foo {
bar: string | undefined;
constructor(bar?: string | undefined);
}

View File

@ -0,0 +1,9 @@
=== tests/cases/compiler/declarationEmitParameterProperty.ts ===
export class Foo {
>Foo : Symbol(Foo, Decl(declarationEmitParameterProperty.ts, 0, 0))
constructor(public bar?: string) {
>bar : Symbol(Foo.bar, Decl(declarationEmitParameterProperty.ts, 1, 14))
}
}

View File

@ -0,0 +1,9 @@
=== tests/cases/compiler/declarationEmitParameterProperty.ts ===
export class Foo {
>Foo : Foo
constructor(public bar?: string) {
>bar : string | undefined
}
}

View File

@ -131,12 +131,12 @@ interface Foo {
}
declare function test1(x: Foo): void;
declare class Bar {
d: number;
d: number | undefined;
e: number;
a: number;
b?: number;
c?: number | undefined;
constructor(d?: number, e?: number);
constructor(d?: number | undefined, e?: number);
f(): number;
g?(): number;
h?(): number;

View File

@ -0,0 +1,6 @@
// @strictNullChecks: true
// @declaration: true
export class Foo {
constructor(public bar?: string) {
}
}