From 7a6fc728398e2d2a3d3a0950056c848cacc3452f Mon Sep 17 00:00:00 2001 From: Zaytsev Kirill Date: Fri, 13 Nov 2020 12:49:58 +0300 Subject: [PATCH] fix: Typehints for modelGetConverter / modelSetConverter --- src/FormularioInput.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/FormularioInput.vue b/src/FormularioInput.vue index ad70f1b..f9f9e06 100644 --- a/src/FormularioInput.vue +++ b/src/FormularioInput.vue @@ -28,6 +28,16 @@ const VALIDATION_BEHAVIOR = { SUBMIT: 'submit', } +interface ModelGetConverter { + (value: U|Empty): U|T|Empty; +} + +interface ModelSetConverter { + (curr: U|T, prev: U|Empty): U|T; +} + +type Empty = null | undefined + @Component({ name: 'FormularioInput', inheritAttrs: false }) export default class FormularioInput extends Vue { @Inject({ default: undefined }) formularioSetter!: Function|undefined @@ -57,8 +67,8 @@ export default class FormularioInput extends Vue { // Affects only observing & setting of local errors @Prop({ default: false }) errorsDisabled!: boolean - @Prop({ default: () => value => value }) modelGetConverter!: Function - @Prop({ default: () => value => value }) modelSetConverter!: Function + @Prop({ default: () => (value: U|Empty): U|T|Empty => value }) modelGetConverter!: ModelGetConverter + @Prop({ default: () => (value: U|T): U|T => value }) modelSetConverter!: ModelSetConverter public proxy: any = this.getInitialValue()