From fa333282d5ad7cfe7819b000b606ec8240b9da9f Mon Sep 17 00:00:00 2001 From: "Mr.Z" Date: Sat, 16 Dec 2023 15:22:29 +0800 Subject: [PATCH] chore: add `typecheck` from ci cann't use with lint-staged lint-staged/lint-staged#468 check all files try fixed microsoft/TypeScript#27379 microsoft/TypeScript#49817 as an alternative https://github.com/gustavopch/tsc-files --- .github/workflows/ci.yml | 3 +++ .lintstagedrc.json | 2 +- package.json | 3 ++- packages/components/customer/__tests__/index.spec.tsx | 2 +- packages/components/message/__tests__/index.spec.tsx | 4 ++-- packages/components/modal/__tests__/index.spec.tsx | 4 ++-- packages/components/notice/__tests__/index.spec.tsx | 4 ++-- packages/components/toast/__tests__/index.spec.tsx | 4 ++-- packages/components/vc/__tests__/index.spec.ts | 2 +- 9 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc7c3ed..b2fdab5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,9 @@ jobs: - run: pnpm install + - name: Run typecheck + run: npm run typecheck + - name: Run unit tests run: npm run test -- --package-name '*' diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 663f36e..5ff416a 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -2,7 +2,7 @@ "**/*.{css,scss}": [ "stylelint --fix" ], - "*.{js,ts,jsx,tsx,md}": [ + "**/*.{js,ts,jsx,tsx,md}": [ "eslint --fix" ] } \ No newline at end of file diff --git a/package.json b/package.json index e792492..5b4e510 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "build": "ddc build --vue-package 'components,hooks' --script-formats=es,cjs,umd,iife --external vue", "test": "ddc test --vue-package 'components,hooks'", "add": "ddc add", - "release": "ddc release" + "release": "ddc release", + "typecheck": "vue-tsc --noEmit --skipLibCheck" }, "scripts-info": { "init": "首次安装", diff --git a/packages/components/customer/__tests__/index.spec.tsx b/packages/components/customer/__tests__/index.spec.tsx index eff99c3..fcc0c45 100644 --- a/packages/components/customer/__tests__/index.spec.tsx +++ b/packages/components/customer/__tests__/index.spec.tsx @@ -43,7 +43,7 @@ describe('index.ts', () => { expect(wrapper.find('.default').text()).toBe('default-slot'); expect(wrapper.find('.content').text()).toBe('content-slot-1'); - await wrapper.setProps({ current: 1 }); + await wrapper.setProps({ current: 1 } as any); expect(wrapper.classes()).toEqual(['child', 'parent']); expect(wrapper.find('.attrs').text()).toBe('1'); diff --git a/packages/components/message/__tests__/index.spec.tsx b/packages/components/message/__tests__/index.spec.tsx index 6de1234..3ad25e8 100644 --- a/packages/components/message/__tests__/index.spec.tsx +++ b/packages/components/message/__tests__/index.spec.tsx @@ -1,6 +1,6 @@ // @vitest-environment jsdom -import { Message } from '@deot/vc-components'; +import { Message, MessageView } from '@deot/vc-components'; import { mount } from '@vue/test-utils'; describe('index.ts', () => { @@ -8,7 +8,7 @@ describe('index.ts', () => { expect(typeof Message).toBe('object'); }); it('create', async () => { - const wrapper = mount(() => ()); + const wrapper = mount(() => ()); expect(wrapper.classes()).toContain('vc-message'); }); diff --git a/packages/components/modal/__tests__/index.spec.tsx b/packages/components/modal/__tests__/index.spec.tsx index 2969069..a2e4b6c 100644 --- a/packages/components/modal/__tests__/index.spec.tsx +++ b/packages/components/modal/__tests__/index.spec.tsx @@ -1,6 +1,6 @@ // @vitest-environment jsdom -import { Modal } from '@deot/vc-components'; +import { Modal, ModalView } from '@deot/vc-components'; import { mount } from '@vue/test-utils'; describe('index.ts', () => { @@ -8,7 +8,7 @@ describe('index.ts', () => { expect(typeof Modal).toBe('object'); }); it('create', async () => { - const wrapper = mount(() => ()); + const wrapper = mount(() => ()); expect(wrapper.classes()).toContain('vc-modal'); }); diff --git a/packages/components/notice/__tests__/index.spec.tsx b/packages/components/notice/__tests__/index.spec.tsx index 426abc4..ec962f1 100644 --- a/packages/components/notice/__tests__/index.spec.tsx +++ b/packages/components/notice/__tests__/index.spec.tsx @@ -1,6 +1,6 @@ // @vitest-environment jsdom -import { Notice } from '@deot/vc-components'; +import { Notice, NoticeView } from '@deot/vc-components'; import { mount } from '@vue/test-utils'; describe('index.ts', () => { @@ -8,7 +8,7 @@ describe('index.ts', () => { expect(typeof Notice).toBe('object'); }); it('create', async () => { - const wrapper = mount(() => ()); + const wrapper = mount(() => ()); expect(wrapper.classes()).toContain('vc-notice'); }); diff --git a/packages/components/toast/__tests__/index.spec.tsx b/packages/components/toast/__tests__/index.spec.tsx index 77919be..e0cc236 100644 --- a/packages/components/toast/__tests__/index.spec.tsx +++ b/packages/components/toast/__tests__/index.spec.tsx @@ -1,6 +1,6 @@ // @vitest-environment jsdom -import { Toast } from '@deot/vc-components'; +import { Toast, ToastView } from '@deot/vc-components'; import { mount } from '@vue/test-utils'; describe('index.ts', () => { @@ -8,7 +8,7 @@ describe('index.ts', () => { expect(typeof Toast).toBe('object'); }); it('create', async () => { - const wrapper = mount(() => ()); + const wrapper = mount(() => ()); expect(wrapper.classes()).toContain('vc-toast'); }); diff --git a/packages/components/vc/__tests__/index.spec.ts b/packages/components/vc/__tests__/index.spec.ts index 301c4b2..d78c91c 100644 --- a/packages/components/vc/__tests__/index.spec.ts +++ b/packages/components/vc/__tests__/index.spec.ts @@ -30,7 +30,7 @@ describe('index.ts', () => { }; VcInstance.configure(); VcInstance.configure(options); - expect((VcInstance.options.Theme.variables as any).background).toBe('white'); + expect((VcInstance.options.Theme!.variables).background).toBe('white'); }); it('VcInstance, globalEvent', async () => {