There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: type import (#2715)
Himself657f2006488e3f
diff --git a/apps/electron/layers/preload/preload.d.ts b/apps/electron/layers/preload/preload.d.tsdeleted file mode 100644index 4ed0b0da0b..0000000000--- a/apps/electron/layers/preload/preload.d.ts+++ /dev/null@@ -1,6 +0,0 @@-/* eslint-disable @typescript-eslint/consistent-type-imports */--declare interface Window {- apis: import('./src/affine-apis').PreloadHandlers;- events: import('./src/affine-apis').MainIPCEventMap;-}diff --git a/apps/electron/layers/preload/src/affine-apis.ts b/apps/electron/layers/preload/src/affine-apis.tsindex 351bd8c3a8..1a79961ab3 100644--- a/apps/electron/layers/preload/src/affine-apis.ts+++ b/apps/electron/layers/preload/src/affine-apis.ts@@ -1,26 +1,6 @@// NOTE: we will generate preload types from this fileimport { ipcRenderer } from 'electron';-// eslint-disable-next-line @typescript-eslint/no-restricted-imports-import type {- MainIPCEventMap,- MainIPCHandlerMap,-} from '../../main/src/exposed';--type WithoutFirstParameter<T> = T extends (_: any, ...args: infer P) => infer R- ? (...args: P) => R- : T;--type HandlersMap<N extends keyof MainIPCHandlerMap> = {- [K in keyof MainIPCHandlerMap[N]]: WithoutFirstParameter<- MainIPCHandlerMap[N][K]- >;-};--export type PreloadHandlers = {- [N in keyof MainIPCHandlerMap]: HandlersMap<N>;-};-type MainExposedMeta = {handlers: [namespace: string, handlerNames: string[]][];events: [namespace: string, eventNames: string[]][];@@ -35,7 +15,7 @@ const meta: MainExposedMeta = (() => {})();// main handlers that can be invoked from the renderer process-const apis: PreloadHandlers = (() => {+const apis: any = (() => {const { handlers: handlersMeta } = meta;const all = handlersMeta.map(([namespace, functionNames]) => {@@ -55,7 +35,7 @@ const apis: PreloadHandlers = (() => {})();// main events that can be listened to from the renderer process-const events: MainIPCEventMap = (() => {+const events: any = (() => {const { events: eventsMeta } = meta;// NOTE: ui may try to listen to a lot of the same events, so we increase the limit...diff --git a/apps/electron/tests/fixture.ts b/apps/electron/tests/fixture.tsindex b71e778a91..1f684f97a8 100644--- a/apps/electron/tests/fixture.ts+++ b/apps/electron/tests/fixture.ts@@ -1,6 +1,3 @@-// eslint-disable-next-line @typescript-eslint/triple-slash-reference-/// <reference path="../layers/preload/preload.d.ts" />-/* eslint-disable no-empty-pattern */import crypto from 'node:crypto';import { join, resolve } from 'node:path';@@ -45,6 +42,7 @@ export const test = base.extend<{});}const logFilePath = await page.evaluate(async () => {+ // @ts-expect-errorreturn window.apis?.debug.logFilePath();});// wat for blocksuite to be loadeddiff --git a/apps/electron/tests/workspace.spec.ts b/apps/electron/tests/workspace.spec.tsindex 64e9b31d65..247e45ceaf 100644--- a/apps/electron/tests/workspace.spec.ts+++ b/apps/electron/tests/workspace.spec.ts@@ -27,6 +27,7 @@ test('move workspace db file', async ({ page, appInfo, workspace }) => {// move db file to tmp folderawait page.evaluate(tmpPath => {+ // @ts-expect-errorwindow.apis?.dialog.setFakeDialogResult({filePath: tmpPath,});@@ -61,6 +62,7 @@ test('export then add', async ({ page, appInfo, workspace }) => {// export db file to tmp folderawait page.evaluate(tmpPath => {+ // @ts-expect-errorwindow.apis?.dialog.setFakeDialogResult({filePath: tmpPath,});@@ -79,6 +81,7 @@ test('export then add', async ({ page, appInfo, workspace }) => {await page.getByTestId('add-or-new-workspace').click();await page.evaluate(tmpPath => {+ // @ts-expect-errorwindow.apis?.dialog.setFakeDialogResult({filePath: tmpPath,});diff --git a/apps/web/src/atoms/index.ts b/apps/web/src/atoms/index.tsindex 86b05ced2c..74f49fa371 100644--- a/apps/web/src/atoms/index.ts+++ b/apps/web/src/atoms/index.ts@@ -50,8 +50,10 @@ rootWorkspacesMetadataAtom.onMount = setAtom => {}, 0);if (environment.isDesktop) {+ // @ts-expect-errorwindow.apis?.workspace.list().then(workspaceIDs => {if (abortController.signal.aborted) return;+ // @ts-expect-errorconst newMetadata = workspaceIDs.map(w => ({id: w[0],flavour: WorkspaceFlavour.LOCAL,@@ -59,6 +61,7 @@ rootWorkspacesMetadataAtom.onMount = setAtom => {setAtom(metadata => {return [...metadata,+ // @ts-expect-error...newMetadata.filter(m => !metadata.find(m2 => m2.id === m.id)),];});diff --git a/apps/web/src/components/affine/create-workspace-modal/index.tsx b/apps/web/src/components/affine/create-workspace-modal/index.tsxindex e92222f286..9f428a41b2 100644--- a/apps/web/src/components/affine/create-workspace-modal/index.tsx+++ b/apps/web/src/components/affine/create-workspace-modal/index.tsx@@ -122,6 +122,7 @@ const useDefaultDBLocation = () => {const [defaultDBLocation, setDefaultDBLocation] = useState('');useEffect(() => {+ // @ts-expect-errorwindow.apis?.db.getDefaultStorageLocation().then(dir => {setDefaultDBLocation(dir);});@@ -147,6 +148,7 @@ const SetDBLocationContent = ({if (result?.filePath) {onConfirmLocation(result.filePath);} else if (result?.error) {+ // @ts-expect-errortoast(t[result.error]());}};@@ -277,6 +279,7 @@ export const CreateWorkspaceModal = ({setStep('set-syncing-mode');} else if (result.error || result.canceled) {if (result.error) {+ // @ts-expect-errortoast(t[result.error]());}onClose();diff --git a/apps/web/src/components/affine/workspace-setting-detail/panel/export/index.tsx b/apps/web/src/components/affine/workspace-setting-detail/panel/export/index.tsxindex 8572eda17c..7fc0355dff 100644--- a/apps/web/src/components/affine/workspace-setting-detail/panel/export/index.tsx+++ b/apps/web/src/components/affine/workspace-setting-detail/panel/export/index.tsx@@ -18,6 +18,7 @@ export const ExportPanel = () => {if (id) {const result = await window.apis?.dialog.saveDBFileAs(id);if (result?.error) {+ // @ts-expect-errortoast(t[result.error]());} else if (!result?.canceled) {toast(t['Export success']());diff --git a/apps/web/src/components/affine/workspace-setting-detail/panel/general/index.tsx b/apps/web/src/components/affine/workspace-setting-detail/panel/general/index.tsxindex b2945caf6d..2db576a187 100644--- a/apps/web/src/components/affine/workspace-setting-detail/panel/general/index.tsx+++ b/apps/web/src/components/affine/workspace-setting-detail/panel/general/index.tsx@@ -27,9 +27,11 @@ const useShowOpenDBFile = (workspaceId: string) => {const [show, setShow] = useState(false);useEffect(() => {if (window.apis && window.events && environment.isDesktop) {+ // @ts-expect-errorwindow.apis.workspace.getMeta(workspaceId).then(meta => {setShow(!!meta.secondaryDBPath);});+ // @ts-expect-errorreturn window.events.workspace.onMetaChange(newMeta => {if (newMeta.workspaceId === workspaceId) {const meta = newMeta.meta;@@ -73,6 +75,7 @@ export const GeneralPanel: React.FC<PanelProps> = ({if (!result?.error && !result?.canceled) {toast(t['Move folder success']());} else if (result?.error) {+ // @ts-expect-errortoast(t[result.error]());}} catch (err) {diff --git a/packages/component/src/components/app-sidebar/app-updater-button/index.jotai.ts b/packages/component/src/components/app-sidebar/app-updater-button/index.jotai.tsindex 1a44e51399..628b43e133 100644--- a/packages/component/src/components/app-sidebar/app-updater-button/index.jotai.ts+++ b/packages/component/src/components/app-sidebar/app-updater-button/index.jotai.ts@@ -35,22 +35,14 @@ function rpcToObservable<});}-type InferTFromEvent<E> = E extends (- callback: (t: infer T) => void-) => () => void- ? T- : never;--type UpdateMeta = InferTFromEvent<typeof window.events.updater.onUpdateReady>;-export const updateReadyAtom = atomWithObservable(() => {- return rpcToObservable(null as UpdateMeta | null, {+ return rpcToObservable(null as any | null, {event: window.events?.updater.onUpdateReady,});});export const updateAvailableAtom = atomWithObservable(() => {- return rpcToObservable(null as UpdateMeta | null, {+ return rpcToObservable(null as any | null, {event: window.events?.updater.onUpdateAvailable,onSubscribe: () => {window.apis?.updater.checkForUpdatesAndNotify();diff --git a/packages/component/src/index.ts b/packages/component/src/index.tsindex 56e85a7bb2..2031c16b8c 100644--- a/packages/component/src/index.ts+++ b/packages/component/src/index.ts@@ -1,6 +1,3 @@-// eslint-disable-next-line @typescript-eslint/triple-slash-reference-/// <reference path="../../../apps/electron/layers/preload/preload.d.ts" />-export * from './components/list-skeleton';export * from './styles';export * from './ui/breadcrumbs';diff --git a/packages/env/src/config.ts b/packages/env/src/config.tsindex 454d43a557..35b5d3b762 100644--- a/packages/env/src/config.ts+++ b/packages/env/src/config.ts@@ -1,12 +1,20 @@/// <reference types="@blocksuite/global" />-// eslint-disable-next-line @typescript-eslint/triple-slash-reference-/// <reference path="./global.d.ts" />import { assertEquals } from '@blocksuite/global/utils';import getConfig from 'next/config';import { z } from 'zod';import { UaHelper } from './ua-helper';+declare global {+ interface Window {+ appInfo: {+ electron: boolean;+ };+ apis: any;+ events: any;+ }+}+export const buildFlagsSchema = z.object({/*** todo: remove this build flag when filter feature is ready.diff --git a/packages/env/env.d.ts b/packages/env/src/env.d.tssimilarity index 100%rename from packages/env/env.d.tsrename to packages/env/src/env.d.tsdiff --git a/packages/env/src/global.d.ts b/packages/env/src/global.d.tsdeleted file mode 100644index 15750c0f60..0000000000--- a/packages/env/src/global.d.ts+++ /dev/null@@ -1,5 +0,0 @@-interface Window {- appInfo: {- electron: bool;- };-}diff --git a/packages/env/tsconfig.json b/packages/env/tsconfig.jsonindex 74e63c8de6..8034f93ce4 100644--- a/packages/env/tsconfig.json+++ b/packages/env/tsconfig.json@@ -1,10 +1,9 @@{"extends": "../../tsconfig.json",+ "include": ["./src"],"compilerOptions": {- "noEmit": false,"composite": true,+ "noEmit": false,"outDir": "lib"- },- "include": ["./src", "env.d.ts", "./src/global.d.ts"],- "exclude": ["lib"]+ }}diff --git a/packages/graphql/tsconfig.json b/packages/graphql/tsconfig.jsonindex 034f4fef72..8034f93ce4 100644--- a/packages/graphql/tsconfig.json+++ b/packages/graphql/tsconfig.json@@ -1,10 +1,9 @@{"extends": "../../tsconfig.json",+ "include": ["./src"],"compilerOptions": {- "target": "ESNext",- "module": "ESNext",- "rootDir": "./src",- "noEmit": true- },- "include": ["src"]+ "composite": true,+ "noEmit": false,+ "outDir": "lib"+ }}diff --git a/packages/hooks/tsconfig.json b/packages/hooks/tsconfig.jsonindex f7940714cb..6398bfec2d 100644--- a/packages/hooks/tsconfig.json+++ b/packages/hooks/tsconfig.json@@ -1,10 +1,10 @@{"extends": "../../tsconfig.json",+ "include": ["./src"],"compilerOptions": {- "outDir": "lib","composite": true,- "noEmit": false+ "noEmit": false,+ "outDir": "lib"},- "include": ["./src"],"references": [{ "path": "../env" }, { "path": "../y-indexeddb" }]}diff --git a/packages/jotai/tsconfig.json b/packages/jotai/tsconfig.jsonindex 8a07cd1e0c..aa1d65db12 100644--- a/packages/jotai/tsconfig.json+++ b/packages/jotai/tsconfig.json@@ -1,14 +1,10 @@{"extends": "../../tsconfig.json",+ "include": ["./src"],"compilerOptions": {- "module": "ESNext",- "target": "ESNext",- "sourceMap": true,+ "composite": true,"noEmit": false,- "outDir": "lib",- "composite": true+ "outDir": "lib"},- "include": ["./src"],- "exclude": ["node_modules"],"references": [{ "path": "../env" }]}diff --git a/packages/plugin-infra/tsconfig.json b/packages/plugin-infra/tsconfig.jsonindex 585d8f9c70..3fcb503086 100644--- a/packages/plugin-infra/tsconfig.json+++ b/packages/plugin-infra/tsconfig.json@@ -1,6 +1,11 @@{"extends": "../../tsconfig.json","include": ["./src"],+ "compilerOptions": {+ "composite": true,+ "noEmit": false,+ "outDir": "lib"+ },"references": [{"path": "../component"@@ -8,10 +13,5 @@{"path": "../workspace"}- ],- "compilerOptions": {- "noEmit": false,- "composite": true,- "outDir": "lib"- }+ ]}diff --git a/packages/storybook/tsconfig.json b/packages/storybook/tsconfig.jsonindex 6f8a61c146..1acec90d8b 100644--- a/packages/storybook/tsconfig.json+++ b/packages/storybook/tsconfig.json@@ -1,7 +1,6 @@{"extends": "../../tsconfig.json",- "exclude": ["lib"],- "include": ["src"],+ "include": ["./src"],"compilerOptions": {"composite": true,"noEmit": false,diff --git a/packages/workspace/src/local/crud.ts b/packages/workspace/src/local/crud.tsindex 721f1114a5..fa5e939b0a 100644--- a/packages/workspace/src/local/crud.ts+++ b/packages/workspace/src/local/crud.ts@@ -102,9 +102,11 @@ export const CRUD: WorkspaceCRUD<WorkspaceFlavour.LOCAL> = {// workspaces in desktopif (window.apis && environment.isDesktop) {+ // @ts-expect-errorconst desktopIds = (await window.apis.workspace.list()).map(([id]) => id);// the ids maybe a subset of the local storageconst moreWorkspaces = desktopIds.filter(+ // @ts-expect-errorid => !allWorkspaceIDs.includes(id));allWorkspaceIDs = [...allWorkspaceIDs, ...moreWorkspaces];diff --git a/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts b/packages/workspace/src/providers/__tests__/sqlite-provider.spec.tsindex a606cb9c53..7a02752171 100644--- a/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts+++ b/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts@@ -39,6 +39,7 @@ vi.stubGlobal('window', {},events: {db: {+ // @ts-expect-erroronExternalUpdate: fn => {triggerDBUpdate = fn;return () => {@@ -113,6 +114,7 @@ describe('SQLite download provider', () => {offlineYdoc.getText('text').insert(0, 'sqlite-world');+ // @ts-expect-errortriggerDBUpdate?.({workspaceId: id + '-another-id',update: Y.encodeStateAsUpdate(offlineYdoc),@@ -121,6 +123,7 @@ describe('SQLite download provider', () => {// not yet updated (because the workspace id is different)expect(workspace.doc.getText('text').toString()).toBe('');+ // @ts-expect-errortriggerDBUpdate?.({workspaceId: id,update: Y.encodeStateAsUpdate(offlineYdoc),diff --git a/packages/workspace/src/providers/index.ts b/packages/workspace/src/providers/index.tsindex ba596287dd..f2d5d69cf2 100644--- a/packages/workspace/src/providers/index.ts+++ b/packages/workspace/src/providers/index.ts@@ -183,6 +183,7 @@ const createSQLiteProvider = (const connect = () => {logger.info('connecting sqlite provider', blockSuiteWorkspace.id);blockSuiteWorkspace.doc.on('update', handleUpdate);+ // @ts-expect-errorunsubscribe = events.db.onExternalUpdate(({ update, workspaceId }) => {if (workspaceId === blockSuiteWorkspace.id) {Y.applyUpdate(blockSuiteWorkspace.doc, update, sqliteOrigin);diff --git a/packages/workspace/src/type.ts b/packages/workspace/src/type.tsindex 0ee7401de0..5554064165 100644--- a/packages/workspace/src/type.ts+++ b/packages/workspace/src/type.ts@@ -1,17 +1,11 @@-// eslint-disable-next-line @typescript-eslint/triple-slash-reference-/// <reference path="../../../apps/electron/layers/preload/preload.d.ts" />-import type { View } from '@affine/component/page-list/filter/shared-types';import type { EditorContainer } from '@blocksuite/editor';import type { Page } from '@blocksuite/store';import type { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';-import type { createStore } from 'jotai';import type { FC, PropsWithChildren } from 'react';import type { Workspace as RemoteWorkspace } from './affine/api';-export type JotaiStore = ReturnType<typeof createStore>;-export enum WorkspaceSubPath {ALL = 'all',SETTING = 'setting',diff --git a/packages/workspace/tsconfig.json b/packages/workspace/tsconfig.jsonindex 9245f68830..2673898994 100644--- a/packages/workspace/tsconfig.json+++ b/packages/workspace/tsconfig.json@@ -1,12 +1,11 @@{"extends": "../../tsconfig.json",+ "include": ["./src"],"compilerOptions": {"composite": true,"noEmit": false,"outDir": "lib"},- "include": ["./src", "./src/affine/api"],- "exclude": ["lib"],"references": [{ "path": "../../tests/fixtures" },{ "path": "../y-indexeddb" },