Skip to content

preset class properties to undefined #12437

Closed
@Jordan-Hall

Description

@Jordan-Hall

TypeScript Version: 2.1.1

Code

class PartialPolicySearchIten {
	public displayValue: string;
	public oriNumber: string;
	public parentName: string;
	public sysNumber: string;
	public systemCode: number;
	public systemName: string;
}

Expected behavior:

class PartialPolicySearchIten {
       constructor() {
        this.displayValue = undefined;
	this.oriNumber = undefined;
	this.parentName = undefined;
	this.sysNumber = undefined;
	this.systemCode = undefined;
	this. systemName = undefined;
       }
}

Actual behavior:
class PartialPolicySearchIten { }

The problem comes when using Reflection it can't find the properties. I would expected that the properties exists as i'm redefining them. Otherwise their very little point is declaring properties of a class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeES NextNew featurers for ECMAScript (a.k.a. ESNext)SuggestionAn idea for TypeScriptWaiting for TC39Unactionable until TC39 reaches some conclusion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions