ソースを参照

refactor: add dts

suzigang 3 年 前
コミット
f4204c6859

+ 4 - 2
package.json

@@ -67,7 +67,8 @@
     "codeformat": "prettier --write .",
     "copydocs": "node ./jd/copymd.js",
     "createTaroConfig": "node ./jd/generate-taro-route.cjs",
-    "attrs": "node ./jd/createAttributes.cjs"
+    "attrs": "node ./jd/createAttributes.cjs",
+    "dts": "vue-tsc --declaration --emitDeclarationOnly --skipLibCheck"
   },
   "standard-version": {
     "scripts": {
@@ -123,7 +124,8 @@
     "vite-plugin-dts": "^1.7.1",
     "vite-plugin-md": "^0.20.4",
     "vue": "^3.2.24",
-    "vue-jest": "^5.0.0-alpha.7"
+    "vue-jest": "^5.0.0-alpha.7",
+    "vue-tsc": "^1.0.9"
   },
   "eslintConfig": {
     "root": true,

+ 70 - 2
pnpm-lock.yaml

@@ -48,6 +48,7 @@ specifiers:
   vue: ^3.2.24
   vue-jest: ^5.0.0-alpha.7
   vue-router: ^4.0.12
+  vue-tsc: ^1.0.9
 
 dependencies:
   '@tarojs/components': 3.5.6_vue@3.2.45
@@ -99,6 +100,7 @@ devDependencies:
   vite-plugin-md: 0.20.4
   vue: 3.2.45
   vue-jest: 5.0.0-alpha.10_aklmwzibdgywp3s3t2c2frdkdi
+  vue-tsc: 1.0.9_typescript@4.9.3
 
 packages:
 
@@ -1401,6 +1403,46 @@ packages:
       vue: 3.2.45
     dev: true
 
+  /@volar/language-core/1.0.9:
+    resolution: {integrity: sha512-5Fty3slLet6svXiJw2YxhYeo6c7wFdtILrql5bZymYLM+HbiZtJbryW1YnUEKAP7MO9Mbeh+TNH4Z0HFxHgIqw==}
+    dependencies:
+      '@volar/source-map': 1.0.9
+      '@vue/reactivity': 3.2.45
+      muggle-string: 0.1.0
+    dev: true
+
+  /@volar/source-map/1.0.9:
+    resolution: {integrity: sha512-fazB/vy5ZEJ3yKx4fabJyGNI3CBkdLkfEIRVu6+1P3VixK0Mn+eqyUIkLBrzGYaeFM3GybhCLCvsVdNz0Fu/CQ==}
+    dependencies:
+      muggle-string: 0.1.0
+    dev: true
+
+  /@volar/typescript/1.0.9:
+    resolution: {integrity: sha512-dVziu+ShQUWuMukM6bvK2v2O446/gG6l1XkTh2vfkccw1IzjfbiP1TWQoNo1ipTfZOtu5YJGYAx+o5HNrGXWfQ==}
+    dependencies:
+      '@volar/language-core': 1.0.9
+    dev: true
+
+  /@volar/vue-language-core/1.0.9:
+    resolution: {integrity: sha512-tofNoR8ShPFenHT1YVMuvoXtXWwoQE+fiXVqSmW0dSKZqEDjWQ3YeXSd0a6aqyKaIbvR7kWWGp34WbpQlwf9Ww==}
+    dependencies:
+      '@volar/language-core': 1.0.9
+      '@volar/source-map': 1.0.9
+      '@vue/compiler-dom': 3.2.45
+      '@vue/compiler-sfc': 3.2.45
+      '@vue/reactivity': 3.2.45
+      '@vue/shared': 3.2.45
+      minimatch: 5.1.0
+      vue-template-compiler: 2.7.14
+    dev: true
+
+  /@volar/vue-typescript/1.0.9:
+    resolution: {integrity: sha512-ZLe4y9YNbviACa7uAMCilzxA76gbbSlKfjspXBzk6fCobd8QCIig+VyDYcjANIlm2HhgSCX8jYTzhCKlegh4mw==}
+    dependencies:
+      '@volar/typescript': 1.0.9
+      '@volar/vue-language-core': 1.0.9
+    dev: true
+
   /@vue/compiler-core/3.2.45:
     resolution: {integrity: sha512-rcMj7H+PYe5wBV3iYeUgbCglC+pbpN8hBLTJvRiK2eKQiWqu+fG9F+8sW99JdL4LQi7Re178UOxn09puSXvn4A==}
     dependencies:
@@ -2703,8 +2745,8 @@ packages:
     engines: {node: '>=10'}
     hasBin: true
     dependencies:
-      is-text-path: 1.0.1
       JSONStream: 1.3.5
+      is-text-path: 1.0.1
       lodash: 4.17.21
       meow: 8.1.2
       split2: 3.2.2
@@ -2880,6 +2922,10 @@ packages:
     resolution: {integrity: sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==}
     dev: true
 
+  /de-indent/1.0.2:
+    resolution: {integrity: sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==}
+    dev: true
+
   /debug/2.6.9:
     resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
     peerDependencies:
@@ -4208,7 +4254,7 @@ packages:
       fs.realpath: 1.0.0
       inflight: 1.0.6
       inherits: 2.0.4
-      minimatch: 3.0.4
+      minimatch: 3.1.2
       once: 1.4.0
       path-is-absolute: 1.0.1
     dev: false
@@ -6170,6 +6216,10 @@ packages:
   /ms/2.1.3:
     resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
 
+  /muggle-string/0.1.0:
+    resolution: {integrity: sha512-Tr1knR3d2mKvvWthlk7202rywKbiOm4rVFLsfAaSIhJ6dt9o47W4S+JMtWhd/PW9Wrdew2/S2fSvhz3E2gkfEg==}
+    dev: true
+
   /mute-stream/0.0.7:
     resolution: {integrity: sha512-r65nCZhrbXXb6dXOACihYApHw2Q6pV0M3V0PSxd74N0+D8nzAdEAITq2oAjA1jVnKI+tGvEBUpqiMh0+rW6zDQ==}
     dev: true
@@ -8638,6 +8688,24 @@ packages:
       vue: 3.2.45
     dev: false
 
+  /vue-template-compiler/2.7.14:
+    resolution: {integrity: sha512-zyA5Y3ArvVG0NacJDkkzJuPQDF8RFeRlzV2vLeSnhSpieO6LK2OVbdLPi5MPPs09Ii+gMO8nY4S3iKQxBxDmWQ==}
+    dependencies:
+      de-indent: 1.0.2
+      he: 1.2.0
+    dev: true
+
+  /vue-tsc/1.0.9_typescript@4.9.3:
+    resolution: {integrity: sha512-vRmHD1K6DmBymNhoHjQy/aYKTRQNLGOu2/ESasChG9Vy113K6CdP0NlhR0bzgFJfv2eFB9Ez/9L5kIciUajBxQ==}
+    hasBin: true
+    peerDependencies:
+      typescript: '*'
+    dependencies:
+      '@volar/vue-language-core': 1.0.9
+      '@volar/vue-typescript': 1.0.9
+      typescript: 4.9.3
+    dev: true
+
   /vue/3.2.45:
     resolution: {integrity: sha512-9Nx/Mg2b2xWlXykmCwiTUCWHbWIj53bnkizBxKai1g61f2Xit700A1ljowpTIM11e3uipOeiPcSqnmBg6gyiaA==}
     dependencies:

+ 1 - 10
src/packages/__VUE/address/index.taro.vue

@@ -137,20 +137,11 @@
 <script lang="ts">
 import { reactive, ref, toRefs, watch, computed, onMounted } from 'vue';
 import { popupProps } from '../popup/props';
+import { RegionData, CustomRegionData } from './type';
 import { createComponent } from '@/packages/utils/create';
 
 const { create, componentName, translate } = createComponent('address');
 
-interface RegionData {
-  id: string;
-  name: string;
-  [key: string]: any;
-}
-interface CustomRegionData {
-  title: string;
-  list: any[];
-}
-
 interface AddressList {
   id?: string | number;
   provinceName: string;

+ 1 - 8
src/packages/__VUE/address/index.vue

@@ -142,16 +142,9 @@
 <script lang="ts">
 import { reactive, ref, toRefs, watch, nextTick, computed, Ref, onMounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
+import { RegionData, CustomRegionData } from './type';
 import { popupProps } from '../popup/props';
 const { componentName, create, translate } = createComponent('address');
-interface RegionData {
-  name: string;
-  [key: string]: any;
-}
-interface CustomRegionData {
-  title: string;
-  list: any[];
-}
 
 interface AddressList {
   id?: string | number;

+ 9 - 0
src/packages/__VUE/address/type.ts

@@ -0,0 +1,9 @@
+export interface RegionData {
+  name: string;
+  [key: string]: any;
+}
+
+export interface CustomRegionData {
+  title: string;
+  list: any[];
+}

+ 1 - 1
src/packages/__VUE/backtop/demo.vue

@@ -35,7 +35,7 @@
   </div>
 </template>
 
-<script>
+<script lang="ts">
 import { createComponent } from '@/packages/utils/create';
 const { createDemo, translate } = createComponent('backtop');
 import { useTranslate } from '@/sites/assets/util/useTranslate';

+ 2 - 50
src/packages/__VUE/calendaritem/index.h5.vue

@@ -71,64 +71,16 @@ const { create, translate } = createComponent('calendar-item');
 import Utils from '@/packages/utils/date';
 import requestAniFrame from '@/packages/utils/raf';
 import { useExpose } from '@/packages/utils/useExpose/index';
+import { MonthInfo, Day, DateInfo } from './type';
 import Taro from '@tarojs/taro';
 const TARO_ENV = Taro.getEnv();
 
-type InputDate = string | string[];
 type StringArr = string[];
-interface TouchParam {
-  startY: number;
-  endY: number;
-  startTime: number;
-  endTime: number;
-  lastY: number;
-  lastTime: number;
-}
-
-interface CalendarState {
-  yearMonthTitle: string;
-  currDate: string | string[];
-  propStartDate: string;
-  propEndDate: string;
-  currentIndex: number;
-  unLoadPrev: boolean;
-  touchParams: TouchParam;
-  transformY: number;
-  translateY: number;
-  scrollDistance: number;
-  defaultData: InputDate;
-  chooseData: (string | string[])[];
-  monthsData: MonthInfo[];
-  dayPrefix: string;
-  startData: InputDate;
-  endData: InputDate;
-  isRange: boolean;
-  timer: number;
-  avgHeight: number;
-  monthsNum: number;
-  defaultRange: number[];
-}
-interface Day {
-  day: string | number;
-  type: string;
-}
 
-interface MonthInfo {
-  curData: string[] | string;
-  title: string;
-  monthData: Day[];
-  cssHeight: number;
-  cssScrollHeight: number;
-}
 interface Dateprop {
   year: string;
   month: string;
 }
-interface DateInfo {
-  year: string;
-  month: string;
-  day: string;
-}
 
 export default create({
   props: {
@@ -219,7 +171,7 @@ export default create({
       return slots.bottomInfo;
     });
 
-    const state: CalendarState = reactive({
+    const state: import('./type').CalendarState = reactive({
       yearMonthTitle: '',
       defaultRange: [],
       currDate: '',

+ 2 - 41
src/packages/__VUE/calendaritem/index.taro.vue

@@ -75,49 +75,10 @@ import Taro from '@tarojs/taro';
 import Utils from '@/packages/utils/date';
 import { useExpose } from '@/packages/utils/useExpose/index';
 import requestAniFrame from '@/packages/utils/raf';
+import { MonthInfo, Day } from './type';
 import NutScrollView from '../scrollView/index.taro.vue';
 const TARO_ENV = Taro.getEnv();
 
-type InputDate = string | string[];
-interface CalendarState {
-  yearMonthTitle: string;
-  containerHeight: string;
-  currDate: any;
-  propStartDate: string;
-  propEndDate: string;
-  currentIndex: number;
-  unLoadPrev: boolean;
-  touchParams: any;
-  transformY: number;
-  translateY: number;
-  scrollDistance: number;
-  defaultData: InputDate;
-  chooseData: any;
-  monthsData: any[];
-  dayPrefix: string;
-  startData: InputDate;
-  endData: InputDate;
-  isRange: boolean;
-  timer: number;
-  avgHeight: number;
-  monthsNum: number;
-  defaultRange: any[];
-  scrollTop: number;
-  compConthsDatas: any[];
-}
-interface Day {
-  day: string | number;
-  type: string;
-}
-
-interface MonthInfo {
-  curData: string[] | string;
-  title: string;
-  monthData: Day[];
-  cssHeight?: number;
-  cssScrollHeight?: number;
-}
-
 export default create({
   components: {
     NutScrollView
@@ -205,7 +166,7 @@ export default create({
       return slots.bottomInfo;
     });
     // state
-    const state: CalendarState = reactive({
+    const state: import('./type').CalendarState = reactive({
       yearMonthTitle: '',
       defaultRange: [0, 1],
       compConthsDatas: [],

+ 2 - 50
src/packages/__VUE/calendaritem/index.vue

@@ -70,63 +70,15 @@ import { createComponent } from '@/packages/utils/create';
 const { create, translate } = createComponent('calendar-item');
 import Utils from '@/packages/utils/date';
 import requestAniFrame from '@/packages/utils/raf';
+import { MonthInfo, Day, DateInfo } from './type';
 import { useExpose } from '@/packages/utils/useExpose/index';
 
-type InputDate = string | string[];
 type StringArr = string[];
-interface TouchParam {
-  startY: number;
-  endY: number;
-  startTime: number;
-  endTime: number;
-  lastY: number;
-  lastTime: number;
-}
-
-interface CalendarState {
-  yearMonthTitle: string;
-  currDate: string | string[];
-  propStartDate: string;
-  propEndDate: string;
-  currentIndex: number;
-  unLoadPrev: boolean;
-  touchParams: TouchParam;
-  transformY: number;
-  translateY: number;
-  scrollDistance: number;
-  defaultData: InputDate;
-  chooseData: (string | string[])[];
-  monthsData: MonthInfo[];
-  dayPrefix: string;
-  startData: InputDate;
-  endData: InputDate;
-  isRange: boolean;
-  timer: number;
-  avgHeight: number;
-  monthsNum: number;
-  defaultRange: number[];
-}
-interface Day {
-  day: string | number;
-  type: string;
-}
 
-interface MonthInfo {
-  curData: string[] | string;
-  title: string;
-  monthData: Day[];
-  cssHeight: number;
-  cssScrollHeight: number;
-}
 interface Dateprop {
   year: string;
   month: string;
 }
-interface DateInfo {
-  year: string;
-  month: string;
-  day: string;
-}
 
 export default create({
   props: {
@@ -216,7 +168,7 @@ export default create({
       return slots.bottomInfo;
     });
 
-    const state: CalendarState = reactive({
+    const state: import('./type').CalendarState = reactive({
       yearMonthTitle: '',
       defaultRange: [],
       currDate: '',

+ 64 - 0
src/packages/__VUE/calendaritem/type.ts

@@ -0,0 +1,64 @@
+export interface TouchParam {
+  startY: number;
+  endY: number;
+  startTime: number;
+  endTime: number;
+  lastY: number;
+  lastTime: number;
+}
+
+export type InputDate = string | string[];
+export type StringArr = string[];
+
+export interface CalendarState {
+  yearMonthTitle: string;
+  currDate: string | string[];
+  propStartDate: string;
+  propEndDate: string;
+  currentIndex: number;
+  unLoadPrev: boolean;
+  touchParams: import('./type').TouchParam;
+  transformY: number;
+  translateY: number;
+  scrollDistance: number;
+  defaultData: InputDate;
+  chooseData: (string | string[])[];
+  monthsData: MonthInfo[];
+  dayPrefix: string;
+  startData: InputDate;
+  endData: InputDate;
+  isRange: boolean;
+  timer: number;
+  avgHeight: number;
+  monthsNum: number;
+  defaultRange: number[];
+}
+export interface Day {
+  day: string | number;
+  type: string;
+}
+
+export interface MonthInfo {
+  curData: string[] | string;
+  title: string;
+  monthData: Day[];
+  cssHeight: number;
+  cssScrollHeight: number;
+}
+export interface Dateprop {
+  year: string;
+  month: string;
+}
+export interface DateInfo {
+  year: string;
+  month: string;
+  day: string;
+}
+
+export interface MonthInfo {
+  curData: string[] | string;
+  title: string;
+  monthData: Day[];
+  cssHeight: number;
+  cssScrollHeight: number;
+}

+ 2 - 5
src/packages/__VUE/elevator/index.taro.vue

@@ -56,15 +56,12 @@
 import { computed, reactive, toRefs, nextTick, ref, Ref, watch } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 import { useExpose } from '@/packages/utils/useExpose/index';
+import { ElevatorData } from './type';
 const { componentName, create } = createComponent('elevator');
 import NutScrollView from '../scrollView/index.taro.vue';
 
 import Taro from '@tarojs/taro';
-interface ElevatorData {
-  name: string;
-  id: number | string;
-  [key: string]: string | number;
-}
+
 export default create({
   components: {
     NutScrollView

+ 2 - 5
src/packages/__VUE/elevator/index.vue

@@ -42,12 +42,9 @@
 import { computed, reactive, toRefs, nextTick, ref, Ref, watch, onMounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 import { useExpose } from '@/packages/utils/useExpose/index';
+import { ElevatorData } from './type';
 const { componentName, create } = createComponent('elevator');
-interface ElevatorData {
-  name: string;
-  id: number | string;
-  [key: string]: string | number;
-}
+
 export default create({
   props: {
     height: {

+ 5 - 0
src/packages/__VUE/elevator/type.ts

@@ -0,0 +1,5 @@
+export interface ElevatorData {
+  name: string;
+  id: number | string;
+  [key: string]: string | number;
+}

+ 2 - 5
src/packages/__VUE/swiperitem/index.taro.vue

@@ -8,12 +8,9 @@
 import { computed, reactive, inject, getCurrentInstance, onUnmounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 import { useExpose } from '@/packages/utils/useExpose/index';
+import { IStyle } from './type';
 const { create, componentName } = createComponent('swiper-item');
-interface IStyle {
-  width?: string;
-  height?: string;
-  transform?: string;
-}
+
 export default create({
   setup(props, { slots }) {
     const parent = inject('parent') as any;

+ 2 - 5
src/packages/__VUE/swiperitem/index.vue

@@ -8,12 +8,9 @@
 import { computed, reactive, inject, getCurrentInstance, onUnmounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 import { useExpose } from '@/packages/utils/useExpose/index';
+import { IStyle } from './type';
 const { create, componentName } = createComponent('swiper-item');
-interface IStyle {
-  width?: string;
-  height?: string;
-  transform?: string;
-}
+
 export default create({
   setup(props, { slots }) {
     const parent = inject('parent') as any;

+ 5 - 0
src/packages/__VUE/swiperitem/type.ts

@@ -0,0 +1,5 @@
+export interface IStyle {
+  width?: string;
+  height?: string;
+  transform?: string;
+}