mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
build: enhance tsconfig type check (#2732)
This commit is contained in:
@@ -29,13 +29,14 @@ export const quitAndInstall = async () => {
|
||||
let lastCheckTime = 0;
|
||||
export const checkForUpdatesAndNotify = async (force = true) => {
|
||||
if (!_autoUpdater) {
|
||||
return; // ?
|
||||
return void 0;
|
||||
}
|
||||
// check every 30 minutes (1800 seconds) at most
|
||||
if (force || lastCheckTime + 1000 * 1800 < Date.now()) {
|
||||
lastCheckTime = Date.now();
|
||||
return await _autoUpdater.checkForUpdatesAndNotify();
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
|
||||
export const registerUpdater = async () => {
|
||||
|
||||
@@ -27,6 +27,7 @@ import { contextBridge, ipcRenderer } from 'electron';
|
||||
if (validateIPC(channel)) {
|
||||
return ipcRenderer.invoke(channel, ...args);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
on(
|
||||
@@ -35,9 +36,8 @@ import { contextBridge, ipcRenderer } from 'electron';
|
||||
) {
|
||||
if (validateIPC(channel)) {
|
||||
ipcRenderer.on(channel, listener);
|
||||
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
once(
|
||||
@@ -46,9 +46,8 @@ import { contextBridge, ipcRenderer } from 'electron';
|
||||
) {
|
||||
if (validateIPC(channel)) {
|
||||
ipcRenderer.once(channel, listener);
|
||||
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
removeListener(
|
||||
@@ -57,9 +56,8 @@ import { contextBridge, ipcRenderer } from 'electron';
|
||||
) {
|
||||
if (validateIPC(channel)) {
|
||||
ipcRenderer.removeListener(channel, listener);
|
||||
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import {
|
||||
CanActivate,
|
||||
createParamDecorator,
|
||||
ExecutionContext,
|
||||
Injectable,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import type { CanActivate, ExecutionContext } from '@nestjs/common';
|
||||
import { createParamDecorator, Injectable, UseGuards } from '@nestjs/common';
|
||||
|
||||
import { PrismaService } from '../../prisma';
|
||||
import { getRequestResponseFromContext } from '../../utils/nestjs';
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
ResolveField,
|
||||
Resolver,
|
||||
} from '@nestjs/graphql';
|
||||
import { Request } from 'express';
|
||||
import type { Request } from 'express';
|
||||
|
||||
import { UserType } from '../users/resolver';
|
||||
import { CurrentUser } from './guard';
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common';
|
||||
import { compare, hash } from '@node-rs/bcrypt';
|
||||
import { User } from '@prisma/client';
|
||||
import type { User } from '@prisma/client';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
import { Config } from '../../config';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { equal, ok } from 'node:assert';
|
||||
import { afterEach, beforeEach, describe, test } from 'node:test';
|
||||
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import type { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { hash } from '@node-rs/bcrypt';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { ArgumentsHost, ExecutionContext } from '@nestjs/common';
|
||||
import {
|
||||
GqlArgumentsHost,
|
||||
GqlContextType,
|
||||
GqlExecutionContext,
|
||||
} from '@nestjs/graphql';
|
||||
import { Request, Response } from 'express';
|
||||
import type { ArgumentsHost, ExecutionContext } from '@nestjs/common';
|
||||
import type { GqlContextType } from '@nestjs/graphql';
|
||||
import { GqlArgumentsHost, GqlExecutionContext } from '@nestjs/graphql';
|
||||
import type { Request, Response } from 'express';
|
||||
|
||||
export function getRequestResponseFromContext(context: ExecutionContext) {
|
||||
switch (context.getType<GqlContextType>()) {
|
||||
|
||||
@@ -30,7 +30,7 @@ export class AffineErrorBoundary extends Component<
|
||||
AffineErrorBoundaryProps,
|
||||
AffineErrorBoundaryState
|
||||
> {
|
||||
public state: AffineErrorBoundaryState = {
|
||||
public override state: AffineErrorBoundaryState = {
|
||||
error: null,
|
||||
};
|
||||
|
||||
@@ -40,11 +40,11 @@ export class AffineErrorBoundary extends Component<
|
||||
return { error };
|
||||
}
|
||||
|
||||
public componentDidCatch(error: AffineError, errorInfo: ErrorInfo) {
|
||||
public override componentDidCatch(error: AffineError, errorInfo: ErrorInfo) {
|
||||
console.error('Uncaught error:', error, errorInfo);
|
||||
}
|
||||
|
||||
public render(): ReactNode {
|
||||
public override render(): ReactNode {
|
||||
if (this.state.error) {
|
||||
const error = this.state.error;
|
||||
if (error instanceof PageNotFoundError) {
|
||||
|
||||
@@ -80,6 +80,7 @@ const PageListEmpty = (props: {
|
||||
if (listType === 'shared') {
|
||||
return t['emptySharedPages']();
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -268,6 +268,7 @@ export const WorkspaceLayout: FC<PropsWithChildren> =
|
||||
affineGlobalChannel.disconnect();
|
||||
};
|
||||
}
|
||||
return;
|
||||
}, [currentWorkspaceId, jotaiWorkspaces]);
|
||||
|
||||
const Provider =
|
||||
|
||||
@@ -12,7 +12,7 @@ const description =
|
||||
export default class AppDocument extends Document<{
|
||||
emotionStyleTags: EmotionJSX.Element[];
|
||||
}> {
|
||||
static getInitialProps = async (ctx: DocumentContext) => {
|
||||
static override getInitialProps = async (ctx: DocumentContext) => {
|
||||
const originalRenderPage = ctx.renderPage;
|
||||
|
||||
const cache = createEmotionCache();
|
||||
@@ -41,7 +41,7 @@ export default class AppDocument extends Document<{
|
||||
emotionStyleTags,
|
||||
};
|
||||
};
|
||||
render() {
|
||||
override render() {
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
|
||||
@@ -63,6 +63,7 @@ const IndexPageInner = () => {
|
||||
} else {
|
||||
console.warn('No target workspace. This should not happen in production');
|
||||
}
|
||||
return;
|
||||
}, [helper, jumpToPage, jumpToSubPath, router, workspaces]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -30,6 +30,7 @@ function useMouseOffset() {
|
||||
el.removeEventListener('mouseleave', onMouseLeave);
|
||||
};
|
||||
}
|
||||
return () => {};
|
||||
}, []);
|
||||
|
||||
return [offset, outside, ref] as const;
|
||||
|
||||
@@ -80,6 +80,7 @@ const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
|
||||
.forEach(dispose => dispose());
|
||||
};
|
||||
}
|
||||
return () => {};
|
||||
}, [editor, editor.page, page, onLoad]);
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
@@ -13,4 +13,5 @@ previewBlockIdAtom.onMount = set => {
|
||||
window.removeEventListener('affine.embed-block-db-click', callback);
|
||||
};
|
||||
}
|
||||
return () => {};
|
||||
};
|
||||
|
||||
@@ -183,6 +183,7 @@ function NotificationCard(props: NotificationCardProps): ReactElement {
|
||||
if (notification.undo) {
|
||||
return notification.undo();
|
||||
}
|
||||
return void 0;
|
||||
}, [notification]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -200,6 +201,7 @@ function NotificationCard(props: NotificationCardProps): ReactElement {
|
||||
h.filter(height => height.notificationKey !== notification.key)
|
||||
);
|
||||
}
|
||||
return () => {};
|
||||
}, [notification.key, setHeights]);
|
||||
return (
|
||||
<Toast.Root
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
export * from './all-page';
|
||||
export * from './components/favorite-tag';
|
||||
export * from './components/new-page-buttton';
|
||||
export * from './components/title-cell';
|
||||
export * from './filter';
|
||||
export * from './operation-cell';
|
||||
export * from './operation-menu-items';
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
export * from './disable-public-link';
|
||||
export * from './share-menu';
|
||||
export * from './share-workspace';
|
||||
export * from './styles';
|
||||
|
||||
@@ -33,4 +33,5 @@ export function findNode<RenderProps>(
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
1
packages/env/package.json
vendored
1
packages/env/package.json
vendored
@@ -12,6 +12,7 @@
|
||||
},
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./api": "./src/api.ts",
|
||||
"./config": "./src/config.ts",
|
||||
"./constant": "./src/constant.ts",
|
||||
"./workspace": "./src/workspace.ts",
|
||||
|
||||
@@ -43,6 +43,7 @@ export function useBlockSuiteWorkspaceAvatarUrl(
|
||||
dispose.dispose();
|
||||
};
|
||||
}
|
||||
return () => {};
|
||||
}, [blockSuiteWorkspace]);
|
||||
return [avatar ?? null, setAvatar] as const;
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ export function setUpLanguage(i: i18n) {
|
||||
}
|
||||
return i.changeLanguage(language);
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
|
||||
// const I18nProvider = I18nextProvider;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// cSpell:ignore Tolgee
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import * as fs from 'node:fs/promises';
|
||||
import * as path from 'node:path';
|
||||
|
||||
import { format } from 'prettier';
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
// cSpell:ignore Tolgee
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { readFile } from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
import { createsNewKey, getRemoteTranslations } from './api.js';
|
||||
import type { TranslationRes } from './utils.js';
|
||||
|
||||
const BASE_JSON_PATH = path.resolve(
|
||||
process.cwd(),
|
||||
'src',
|
||||
'resources',
|
||||
'en.json'
|
||||
);
|
||||
const BASE_JSON_PATH = resolve(process.cwd(), 'src', 'resources', 'en.json');
|
||||
const BASE_LANGUAGES = 'en' as const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Empty } from '@affine/component';
|
||||
import { toast } from '@affine/component';
|
||||
import { AffineLoading } from '@affine/component/affine-loading';
|
||||
import { PageListTrashView } from '@affine/component/page-list/all-page';
|
||||
import { PageList } from '@affine/component/page-list/all-page';
|
||||
import { NewPageButton } from '@affine/component/page-list/components/new-page-buttton';
|
||||
import type { OperationCellProps } from '@affine/component/page-list/operation-cell';
|
||||
import { OperationCell } from '@affine/component/page-list/operation-cell';
|
||||
import type { OperationCellProps } from '@affine/component/page-list';
|
||||
import { PageListTrashView } from '@affine/component/page-list';
|
||||
import { PageList } from '@affine/component/page-list';
|
||||
import { NewPageButton } from '@affine/component/page-list';
|
||||
import { OperationCell } from '@affine/component/page-list';
|
||||
import { PageIcon } from '@blocksuite/icons';
|
||||
import { expect } from '@storybook/jest';
|
||||
import type { StoryFn } from '@storybook/react';
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { toast } from '@affine/component';
|
||||
import { PublicLinkDisableModal } from '@affine/component/share-menu/disable-public-link';
|
||||
import {
|
||||
PublicLinkDisableModal,
|
||||
StyledDisableButton,
|
||||
} from '@affine/component/share-menu';
|
||||
import { ShareMenu } from '@affine/component/share-menu/share-menu';
|
||||
import { StyledDisableButton } from '@affine/component/share-menu/styles';
|
||||
import type {
|
||||
AffineLegacyCloudWorkspace,
|
||||
LocalWorkspace,
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib"
|
||||
"outDir": "lib",
|
||||
"paths": {
|
||||
"@affine/component": ["../component/src"],
|
||||
"@affine/component/*": ["../component/src/components/*"]
|
||||
}
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
|
||||
@@ -75,6 +75,7 @@ const signInWithElectron = async (firebaseAuth: FirebaseAuth) => {
|
||||
const user = await signInWithCredential(firebaseAuth, credential);
|
||||
return await user.user.getIdToken();
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
|
||||
export const clearLoginStorage = () => {
|
||||
|
||||
@@ -48,6 +48,7 @@ rootCurrentWorkspaceIdAtom.onMount = set => {
|
||||
Router.events.off('routeChangeStart', callback);
|
||||
};
|
||||
}
|
||||
return () => {};
|
||||
};
|
||||
|
||||
export const rootCurrentPageIdAtom = atom<string | null>(null);
|
||||
@@ -68,6 +69,7 @@ rootCurrentPageIdAtom.onMount = set => {
|
||||
Router.events.off('routeChangeStart', callback);
|
||||
};
|
||||
}
|
||||
return () => {};
|
||||
};
|
||||
|
||||
// current editor atom, each app should have only one editor in the same time
|
||||
|
||||
@@ -101,7 +101,7 @@ export class CallbackSet extends Set<() => void> {
|
||||
this.#ready = v;
|
||||
}
|
||||
|
||||
add(cb: () => void) {
|
||||
override add(cb: () => void) {
|
||||
if (this.ready) {
|
||||
cb();
|
||||
return this;
|
||||
@@ -112,7 +112,7 @@ export class CallbackSet extends Set<() => void> {
|
||||
return super.add(cb);
|
||||
}
|
||||
|
||||
delete(cb: () => void) {
|
||||
override delete(cb: () => void) {
|
||||
if (this.has(cb)) {
|
||||
return super.delete(cb);
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ export async function tryMigrate(
|
||||
}
|
||||
);
|
||||
}
|
||||
return void 0;
|
||||
})
|
||||
);
|
||||
localStorage.setItem(`${dbName}-migration`, 'true');
|
||||
|
||||
@@ -80,7 +80,7 @@ export class IndexedDBVectorStore extends VectorStore {
|
||||
return result;
|
||||
}
|
||||
|
||||
static async fromTexts(
|
||||
static override async fromTexts(
|
||||
texts: string[],
|
||||
metadatas: object[] | object,
|
||||
embeddings: Embeddings,
|
||||
@@ -98,7 +98,7 @@ export class IndexedDBVectorStore extends VectorStore {
|
||||
return IndexedDBVectorStore.fromDocuments(docs, embeddings, dbConfig);
|
||||
}
|
||||
|
||||
static async fromDocuments(
|
||||
static override async fromDocuments(
|
||||
docs: Document[],
|
||||
embeddings: Embeddings,
|
||||
dbConfig?: MemoryVectorStoreArgs
|
||||
|
||||
@@ -1,28 +1,57 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"target": "ESNext",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
// Classification follows https://www.typescriptlang.org/tsconfig
|
||||
|
||||
// Type Checking
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
// FIXME: add this back
|
||||
"noUncheckedIndexedAccess": false,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
// exactOptionalPropertyTypes: false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
// noPropertyAccessFromIndexSignature: false,
|
||||
// noUncheckedIndexedAccess: false,
|
||||
// noUnusedLocals: false,
|
||||
// noUnusedParameters: false,
|
||||
"useUnknownInCatchVariables": true,
|
||||
|
||||
// Modules
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "Node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
|
||||
// Project
|
||||
"incremental": true,
|
||||
"composite": true,
|
||||
// Emit
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
// skip type emit for @internal types
|
||||
// "stripInternal": true,
|
||||
|
||||
// JavaScript Support
|
||||
"allowJs": false,
|
||||
"checkJs": false,
|
||||
|
||||
// Interop Constraints
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
|
||||
// Language and Environment
|
||||
"jsx": "react-jsx",
|
||||
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"baseUrl": ".",
|
||||
|
||||
// Projects
|
||||
"composite": true,
|
||||
"incremental": true,
|
||||
|
||||
// Completeness
|
||||
"skipLibCheck": true, // skip all type checks for .d.ts files
|
||||
|
||||
"paths": {
|
||||
"@affine/component": ["./packages/component/src/index"],
|
||||
"@affine/component/*": [
|
||||
|
||||
Reference in New Issue
Block a user