From 3eb6aeac4bb938fd6e1332db2b7c66260a978bc1 Mon Sep 17 00:00:00 2001 From: TechQuery Date: Thu, 20 Jun 2024 02:38:53 +0800 Subject: [PATCH] [fix] some Type detail bugs --- package.json | 6 +++--- pnpm-lock.yaml | 24 ++++++++++++------------ source/component/AuditBar.tsx | 8 ++++---- source/component/CardsPage.tsx | 19 +++++++------------ source/page/Map/index.tsx | 3 +-- tsconfig.json | 2 +- 6 files changed, 28 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index e450ca3..15ac71c 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "dependencies": { "boot-cell": "^2.0.0-beta.29", "browser-unhandled-rejection": "^1.0.2", - "cell-router": "^3.0.0-rc.7", + "cell-router": "^3.0.0-rc.8", "classnames": "^2.5.1", "dom-renderer": "^2.1.8", "echarts": "^5.5.0", @@ -34,7 +34,7 @@ "@parcel/transformer-less": "~2.12.0", "@parcel/transformer-typescript-tsc": "~2.12.0", "@parcel/transformer-webmanifest": "~2.12.0", - "@types/node": "^18.19.36", + "@types/node": "^18.19.37", "@typescript-eslint/eslint-plugin": "^7.13.1", "@typescript-eslint/parser": "^7.13.1", "buffer": "^6.0.3", @@ -72,7 +72,7 @@ "browserslist": "> 0.5%, last 2 versions, not dead, IE 11", "scripts": { "prepare": "husky", - "test": "lint-staged", + "test": "lint-staged && tsc --noEmit", "clean": "rm -rf .parcel-cache/ dist/", "start:local": "npm run clean && cross-env HTTP_ENV=local parcel source/index.html --open", "start:remote": "npm run clean && cross-env HTTP_ENV=remote parcel source/index.html --open", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index de79e93..1218fc1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: ^1.0.2 version: 1.0.2 cell-router: - specifier: ^3.0.0-rc.7 - version: 3.0.0-rc.7(element-internals-polyfill@1.3.11)(typescript@5.4.5) + specifier: ^3.0.0-rc.8 + version: 3.0.0-rc.8(element-internals-polyfill@1.3.11)(typescript@5.4.5) classnames: specifier: ^2.5.1 version: 2.5.1 @@ -67,8 +67,8 @@ importers: specifier: ~2.12.0 version: 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) '@types/node': - specifier: ^18.19.36 - version: 18.19.36 + specifier: ^18.19.37 + version: 18.19.37 '@typescript-eslint/eslint-plugin': specifier: ^7.13.1 version: 7.13.1(@typescript-eslint/parser@7.13.1(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5) @@ -1584,8 +1584,8 @@ packages: '@types/minimist@1.2.5': resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} - '@types/node@18.19.36': - resolution: {integrity: sha512-tX1BNmYSWEvViftB26VLNxT6mEr37M7+ldUtq7rlKnv4/2fKYsJIOmqJAjT6h1DNuwQjIKgw3VJ/Dtw3yiTIQw==} + '@types/node@18.19.37': + resolution: {integrity: sha512-Pi53fdVMk7Ig5IfAMltQQMgtY7xLzHaEous8IQasYsdQbYK3v90FkxI3XYQCe/Qme58pqp14lXJIsFmGP8VoZQ==} '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} @@ -1850,8 +1850,8 @@ packages: caniuse-lite@1.0.30001587: resolution: {integrity: sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA==} - cell-router@3.0.0-rc.7: - resolution: {integrity: sha512-59jKPsXlPV8SgFnfp0cllANfSQBQeQBM/7HoLvDCh8Q2FnRkizQRToUPqemhYlyOegWGpJ5+dFlgt8NjiIaanQ==} + cell-router@3.0.0-rc.8: + resolution: {integrity: sha512-Gv6qrAqBMNu6GA9fN4a44yncGe0MNi70sUQX8/5R8bFWyVllU3veoi+8Yz8YWDPLeiaUy3/yr1H5EXd82O0ZPQ==} chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} @@ -5761,7 +5761,7 @@ snapshots: '@types/keyv@3.1.4': dependencies: - '@types/node': 18.19.36 + '@types/node': 18.19.37 '@types/lodash@4.17.5': {} @@ -5769,7 +5769,7 @@ snapshots: '@types/minimist@1.2.5': {} - '@types/node@18.19.36': + '@types/node@18.19.37': dependencies: undici-types: 5.26.5 @@ -5779,7 +5779,7 @@ snapshots: '@types/responselike@1.0.3': dependencies: - '@types/node': 18.19.36 + '@types/node': 18.19.37 '@types/trusted-types@2.0.7': {} @@ -6087,7 +6087,7 @@ snapshots: caniuse-lite@1.0.30001587: {} - cell-router@3.0.0-rc.7(element-internals-polyfill@1.3.11)(typescript@5.4.5): + cell-router@3.0.0-rc.8(element-internals-polyfill@1.3.11)(typescript@5.4.5): dependencies: '@swc/helpers': 0.5.11 dom-renderer: 2.1.8(typescript@5.4.5) diff --git a/source/component/AuditBar.tsx b/source/component/AuditBar.tsx index c02cb1c..34186e3 100644 --- a/source/component/AuditBar.tsx +++ b/source/component/AuditBar.tsx @@ -4,11 +4,11 @@ import { Button, ButtonGroup } from 'boot-cell'; import { TimeUnitName } from '../utility'; import { DataItem, Organization } from '../service'; -import { session, BaseModel, VerifiableModel } from '../model'; +import { session, VerifiableModel } from '../model'; -export interface AuditBarProps extends DataItem, Organization { +export interface AuditBarProps extends DataItem, Organization { scope: string; - model: BaseModel; + model: VerifiableModel; } const TimeStamp: FC> = ({ @@ -26,7 +26,7 @@ const TimeStamp: FC> = ({ ); }; -export const AuditBar: FC = observer(props => { +export const AuditBar = observer(function (props: AuditBarProps) { const { createdAt, updatedAt, diff --git a/source/component/CardsPage.tsx b/source/component/CardsPage.tsx index fa10ebd..635c702 100644 --- a/source/component/CardsPage.tsx +++ b/source/component/CardsPage.tsx @@ -7,26 +7,24 @@ import { TouchHandler } from 'boot-cell'; import { CustomElement } from 'web-utility'; +import { Filter } from 'mobx-restful'; import { DistrictEvent, DistrictFilter, District } from './DistrictFilter'; import { VerifiableModel, session } from '../model'; +import { DataItem } from '../service'; -export abstract class CardsPage +export abstract class CardsPage extends HTMLElement implements CustomElement { abstract scope: string; - abstract model: VerifiableModel; + abstract model: VerifiableModel; abstract name: string; districtFilter = false; - filter: District & { verified?: boolean } = { + filter = { verified: !session.hasRole('Admin') - }; - - mountedCallback() { - this.model.getList(this.filter); - } + } as Filter & District & { verified?: boolean }; disconnectedCallback() { this.model.clear(); @@ -37,10 +35,7 @@ export abstract class CardsPage }; changeDistrict = ({ detail }: DistrictEvent) => - this.model.getList( - (this.filter = { ...detail, verified: this.filter.verified }), - 1 - ); + this.model.getList((this.filter = { ...this.filter, ...detail }), 1); changeVerified = ({ target }: Event) => { const { checked } = target as HTMLInputElement; diff --git a/source/page/Map/index.tsx b/source/page/Map/index.tsx index f021836..c192c4b 100644 --- a/source/page/Map/index.tsx +++ b/source/page/Map/index.tsx @@ -3,7 +3,7 @@ import { observable } from 'mobx'; import { SpinnerBox } from 'boot-cell'; import { CustomElement, Hour } from 'web-utility'; -import { HierarchicalVirusMap, VirusChart } from './component'; +import { HierarchicalVirusMap } from './component'; import { Series, ProvinceData, @@ -65,7 +65,6 @@ export default class MapsPage extends HTMLElement implements CustomElement { resolution={resolution} /> )} - ); } diff --git a/tsconfig.json b/tsconfig.json index 9d7d190..644f56c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "useDefineForClassFields": true, "jsx": "react-jsx", "jsxImportSource": "dom-renderer", - "lib": ["ES2023", "DOM"] + "lib": ["ESNext", "DOM"] }, "include": ["source/**/*", "*.ts"] }