mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
83 lines
2.4 KiB
TypeScript
83 lines
2.4 KiB
TypeScript
//// [tests/cases/compiler/parameterPropertyWithDefaultValueExtended.ts] ////
|
|
|
|
//// [parameterPropertyWithDefaultValueExtended.ts]
|
|
// Test with default value - should not have undefined
|
|
export class WithDefault {
|
|
constructor(readonly timestamp = new Date()) {}
|
|
}
|
|
|
|
// Test without default value but optional - should have undefined
|
|
export class WithoutDefault {
|
|
constructor(readonly timestamp?: Date) {}
|
|
}
|
|
|
|
// Test with explicit undefined type - should keep it
|
|
export class ExplicitUndefined {
|
|
constructor(readonly timestamp: Date | undefined = new Date()) {}
|
|
}
|
|
|
|
// Test private parameter property with default value
|
|
export class PrivateWithDefault {
|
|
constructor(private timestamp = new Date()) {}
|
|
}
|
|
|
|
// Test public parameter property with default value
|
|
export class PublicWithDefault {
|
|
constructor(public timestamp = new Date()) {}
|
|
}
|
|
|
|
//// [parameterPropertyWithDefaultValueExtended.js]
|
|
// Test with default value - should not have undefined
|
|
export class WithDefault {
|
|
constructor(timestamp = new Date()) {
|
|
this.timestamp = timestamp;
|
|
}
|
|
}
|
|
// Test without default value but optional - should have undefined
|
|
export class WithoutDefault {
|
|
constructor(timestamp) {
|
|
this.timestamp = timestamp;
|
|
}
|
|
}
|
|
// Test with explicit undefined type - should keep it
|
|
export class ExplicitUndefined {
|
|
constructor(timestamp = new Date()) {
|
|
this.timestamp = timestamp;
|
|
}
|
|
}
|
|
// Test private parameter property with default value
|
|
export class PrivateWithDefault {
|
|
constructor(timestamp = new Date()) {
|
|
this.timestamp = timestamp;
|
|
}
|
|
}
|
|
// Test public parameter property with default value
|
|
export class PublicWithDefault {
|
|
constructor(timestamp = new Date()) {
|
|
this.timestamp = timestamp;
|
|
}
|
|
}
|
|
|
|
|
|
//// [parameterPropertyWithDefaultValueExtended.d.ts]
|
|
export declare class WithDefault {
|
|
readonly timestamp: Date;
|
|
constructor(timestamp?: Date);
|
|
}
|
|
export declare class WithoutDefault {
|
|
readonly timestamp?: Date | undefined;
|
|
constructor(timestamp?: Date | undefined);
|
|
}
|
|
export declare class ExplicitUndefined {
|
|
readonly timestamp: Date | undefined;
|
|
constructor(timestamp?: Date | undefined);
|
|
}
|
|
export declare class PrivateWithDefault {
|
|
private timestamp;
|
|
constructor(timestamp?: Date);
|
|
}
|
|
export declare class PublicWithDefault {
|
|
timestamp: Date;
|
|
constructor(timestamp?: Date);
|
|
}
|