vue-property-decorator icon indicating copy to clipboard operation
vue-property-decorator copied to clipboard

[Feature Request] @Private decorator for private member within typescript class style component ?

Open bruceauyeung opened this issue 5 years ago • 2 comments

i am writing typescript class style vue component. is there any decorator can mark a member private ? it may looks like:

export default class Human extends Vue {
  @Private private name:string;
}

i expect this decorator can ensure:

  1. the marked member can not be set within vue template, such as <input v-model="name" />
  2. the marked member can be read within vue template, such as {{ name }}
  3. the marked member can be read/set within Human class itself ,such as this.name = 'bruce'
  4. compiler can throw error if it's referenced by a wrong name or assigned with a value of different data type. for example:
    1. typescript compiler will complain member nAme doesn't exist when user try to read this.nAme,
    2. typescript compiler will complain member name is of type string but assigned with a number when user try to this.name=1.

bruceauyeung avatar Oct 25 '19 20:10 bruceauyeung

May be try :

@Prop() private name: string; ?

yeria-t avatar Feb 05 '20 09:02 yeria-t

@Prop() annotated members are expected to and can indeed be changed by parent components (outside of enclosing class), this breaks rule #1

@yeria-t

bruceauyeung avatar Feb 10 '20 00:02 bruceauyeung