Browse Source

fix: ts 类型修改 (#1916)

peixinyu 3 years ago
parent
commit
a944c2bc99

+ 3 - 1
src/packages/__VUE/collapseitem/index.taro.vue

@@ -109,7 +109,7 @@ export default create({
       }
     };
     relation(getCurrentInstance() as ComponentInternalInstance);
-    const proxyData: any = reactive({
+    const proxyData = reactive({
       icon: parent.props.icon,
       iconSize: parent.props.iconSize,
       iconColor: parent.props.iconColor,
@@ -159,6 +159,7 @@ export default create({
       }
       nextTick(() => {
         // const query = Taro.createSelectorQuery();
+        // @ts-ignore
         const query = Taro.getEnv() === 'ALIPAY' ? my.createSelectorQuery() : Taro.createSelectorQuery();
         query.selectAll('.nut-collapse__item-wrapper__content').boundingClientRect();
         query.exec((res: any[]) => {
@@ -252,6 +253,7 @@ export default create({
     };
 
     const getRefHeight = () => {
+      // @ts-ignore
       const query = Taro.getEnv() === 'ALIPAY' ? my.createSelectorQuery() : Taro.createSelectorQuery();
       query.selectAll('.nut-collapse__item-wrapper__content').boundingClientRect();
       query.exec((res: any[]) => {

+ 2 - 2
src/packages/__VUE/collapseitem/index.vue

@@ -222,8 +222,8 @@ export default create({
       });
     };
     onMounted(() => {
-      const MutationObserver: any =
-        window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
+      // const MutationObserver: any =
+      //   window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
       var observer = new MutationObserver(() => {
         animation();
       });

+ 2 - 2
src/packages/__VUE/countup/index.taro.vue

@@ -35,7 +35,7 @@
                 'px',
               backgroundImage: 'url(' + customBgImg + ')',
               backgroundPosition:
-                '0 ' + -(String(relNum)[index] * numHeight + customSpacNum * String(relNum)[index]) + 'px',
+                '0 ' + -(+String(relNum)[index] * numHeight + customSpacNum * +String(relNum)[index]) + 'px',
               transition: 'all linear ' + during / 10 + 'ms'
             }"
           ></view>
@@ -69,7 +69,7 @@
           v-for="(val, index) of num_total_len"
           :key="val"
           :style="{
-            all: turnNumber(index),
+            all: turnNumber(index) as any,
             top: topNumber(index),
             left: numWidth * (index > num_total_len - pointNum - 1 ? index * 1.1 : index) + 'px'
           }"

+ 7 - 4
src/packages/__VUE/countup/index.vue

@@ -35,7 +35,8 @@
                 'px',
               backgroundImage: 'url(' + customBgImg + ')',
               backgroundPositionX: '0',
-              backgroundPositionY: -(String(relNum)[index] * numHeight + customSpacNum * String(relNum)[index]) + 'px',
+              backgroundPositionY:
+                -(+String(relNum)[index] * numHeight + customSpacNum * +String(relNum)[index]) + 'px',
               transition: 'all linear ' + during / 10 + 'ms'
             }"
           ></view>
@@ -64,7 +65,7 @@
         }"
       >
         <view
-          :ref="setRef"
+          :ref="(el) => setRef(el)"
           class="nut-countup__number-item"
           v-for="(val, index) of num_total_len"
           :key="val"
@@ -215,8 +216,10 @@ export default create({
   setup(props, { emit }) {
     const runNumberImg = ref(null);
     const numberItemRef = ref<any>([]);
-    const setRef = (el: Element) => {
-      numberItemRef.value.push(el);
+    const setRef = (el: any) => {
+      if (el) {
+        numberItemRef.value.push(el);
+      }
     };
     const data: IData = reactive({
       valFlag: false,

+ 1 - 1
src/packages/__VUE/griditem/index.taro.vue

@@ -60,7 +60,7 @@ export default create({
   emits: ['click'],
   setup(props, { emit }) {
     const Parent = useInject<{ props: Required<GridProps> }>(GRID_KEY);
-    if (!Parent.parent) return;
+    if (!Parent.parent) return {} as any;
     const index = Parent.index;
     const parent = Parent.parent.props;
 

+ 1 - 1
src/packages/__VUE/griditem/index.vue

@@ -61,7 +61,7 @@ export default create({
   emits: ['click'],
   setup(props, { emit }) {
     const Parent = useInject<{ props: Required<GridProps> }>(GRID_KEY);
-    if (!Parent.parent) return;
+    if (!Parent.parent) return {} as any;
     const index = Parent.index;
     const parent = Parent.parent.props;
 

+ 1 - 1
src/packages/__VUE/popover/index.taro.vue

@@ -62,7 +62,7 @@ export default create({
   },
   props: {
     visible: { type: Boolean, default: false },
-    list: { type: Array, default: [] },
+    list: { type: Array as PropType<import('./type').PopoverList[]>, default: [] },
     theme: { type: String as PropType<import('./type').PopoverTheme>, default: 'light' },
     location: { type: String as PropType<import('./type').PopoverLocation>, default: 'bottom' },
     offset: { type: Array, default: [0, 12] },

+ 1 - 1
src/packages/__VUE/popover/index.vue

@@ -49,7 +49,7 @@ export default create({
   },
   props: {
     visible: { type: Boolean, default: false },
-    list: { type: Array, default: [] },
+    list: { type: Array as PropType<import('./type').PopoverList[]>, default: [] },
     theme: { type: String as PropType<import('./type').PopoverTheme>, default: 'light' },
     location: { type: String as PropType<import('./type').PopoverLocation>, default: 'bottom' },
     offset: { type: Array, default: [0, 12] },

+ 8 - 0
src/packages/__VUE/popover/type.ts

@@ -13,3 +13,11 @@ export type PopoverLocation =
   | 'left-end'
   | 'right-start'
   | 'right-end';
+
+export type PopoverList = {
+  name: string;
+  icon?: string;
+  disabled?: boolean;
+  className?: any;
+  [key: PropertyKey]: any;
+};

+ 6 - 1
src/packages/__VUE/searchbar/index.taro.vue

@@ -27,7 +27,12 @@
             :style="styleSearchbar"
           />
         </form>
-        <view @click="handleClear" class="nut-searchbar__input-clear" v-if="clearable" v-show="modelValue.length > 0">
+        <view
+          @click="handleClear"
+          class="nut-searchbar__input-clear"
+          v-if="clearable"
+          v-show="String(modelValue).length > 0"
+        >
           <nut-icon :name="clearIcon" size="12" color="#555"></nut-icon>
         </view>
       </view>

+ 7 - 8
src/packages/__VUE/signature/index.taro.vue

@@ -6,7 +6,6 @@
         class="spcanvas"
         id="spcanvas"
         canvasId="spcanvas"
-        canvas-id="spcanvas"
         type="2d"
         disable-scroll="true"
         @touchstart="startEventHandler"
@@ -64,14 +63,14 @@ export default create({
     });
     const spcanvas: any = ref<HTMLElement | null>(null);
 
-    const state: any = reactive({
+    const state = reactive({
       canvas: null,
       canvasHeight: 0,
       canvasWidth: 0,
-      ctx: null
+      ctx: null as any
     });
 
-    const startEventHandler = (event: MouseEvent) => {
+    const startEventHandler = (event: TouchEvent) => {
       event.preventDefault();
       if (!state.ctx) {
         return false;
@@ -82,15 +81,15 @@ export default create({
       state.ctx.strokeStyle = props.strokeStyle;
     };
 
-    const moveEventHandler = (event: { preventDefault: () => void; changedTouches: any[] }) => {
+    const moveEventHandler = (event: TouchEvent) => {
       event.preventDefault();
       if (!state.ctx) {
         return false;
       }
       let evt = event.changedTouches[0];
       emit('signing', evt);
-      let mouseX = evt.x || evt.clientX;
-      let mouseY = evt.y || evt.clientY;
+      let mouseX = evt.clientX;
+      let mouseY = evt.clientY;
 
       if (Taro.getEnv() === 'WEB') {
         let coverPos = spcanvas.value.getBoundingClientRect();
@@ -137,7 +136,7 @@ export default create({
           Taro.canvasToTempFilePath({
             canvas: res[0].node,
             canvasId: 'spcanvas',
-            fileType: props.type,
+            fileType: props.type as any,
             success: function (result) {
               emit('confirm', state.canvas, result.tempFilePath);
             },

+ 2 - 2
src/packages/__VUE/signature/index.vue

@@ -61,10 +61,10 @@ export default create({
         [`${props.customClass}`]: props.customClass
       };
     });
-    const state: any = reactive({
+    const state = reactive({
       canvasHeight: 0,
       canvasWidth: 0,
-      ctx: null,
+      ctx: null as any,
       isSupportTouch: 'ontouchstart' in window,
       events:
         'ontouchstart' in window

+ 1 - 1
src/packages/__VUE/textarea/index.taro.vue

@@ -33,7 +33,7 @@ const { componentName, create, translate } = createComponent('textarea');
 export default create({
   props: {
     modelValue: {
-      type: [String, Number],
+      type: String,
       default: ''
     },
     textAlign: {

+ 1 - 1
src/packages/__VUE/textarea/index.vue

@@ -27,7 +27,7 @@ const { componentName, create, translate } = createComponent('textarea');
 export default create({
   props: {
     modelValue: {
-      type: [String, Number],
+      type: String,
       default: ''
     },
     textAlign: {