build: perform TypeCheck for all packages (#2573)

Co-authored-by: himself65 <himself65@outlook.com>
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
LongYinan
2023-05-31 20:49:56 +08:00
committed by GitHub
parent 78410f531a
commit 1ea445ab15
81 changed files with 434 additions and 241 deletions

View File

@@ -2,6 +2,6 @@
// This file contains the main process events
// It will guide preload and main process on the correct event types and payloads
export type MainIPCHandlerMap = typeof import('./main/src/exposed').handlers;
declare type MainIPCHandlerMap = typeof import('./main/src/exposed').handlers;
export type MainIPCEventMap = typeof import('./main/src/exposed').events;
declare type MainIPCEventMap = typeof import('./main/src/exposed').events;

View File

@@ -6,8 +6,6 @@ import { v4 } from 'uuid';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import * as Y from 'yjs';
import type { MainIPCHandlerMap } from '../../../constraints';
const registeredHandlers = new Map<
string,
((...args: any[]) => Promise<any>)[]

View File

@@ -1,8 +1,8 @@
import { app, Menu } from 'electron';
import { isMacOS } from '../../../utils';
import { revealLogFile } from '../logger';
import { checkForUpdatesAndNotify } from '../updater';
import { isMacOS } from '../utils';
import { applicationMenuSubjects } from './subject';
// Unique id for menuitems

View File

@@ -44,9 +44,9 @@ export abstract class BaseSQLiteAdapter {
}
// todo: what if SQLite DB wrapper later is not sync?
connect() {
connect(): Database | undefined {
if (this.db) {
return;
return this.db;
}
logger.log(`[SQLiteAdapter][${this.role}] open db`, this.path);
const db = (this.db = sqlite(this.path));

View File

@@ -1,3 +1,4 @@
import type { Database } from 'better-sqlite3';
import { Subject } from 'rxjs';
import * as Y from 'yjs';
@@ -33,7 +34,7 @@ export class WorkspaceSQLiteDB extends BaseSQLiteAdapter {
return this.yDoc.getMap('space:meta').get('name') as string;
};
async init() {
async init(): Promise<Database | undefined> {
const db = super.connect();
if (!this.firstConnected) {

View File

@@ -29,7 +29,7 @@ export async function revealDBFile(workspaceId: string) {
}
// provide a backdoor to set dialog path for testing in playwright
interface FakeDialogResult {
export interface FakeDialogResult {
canceled?: boolean;
filePath?: string;
filePaths?: string[];
@@ -63,7 +63,7 @@ const ErrorMessages = [
type ErrorMessage = (typeof ErrorMessages)[number];
interface SaveDBFileResult {
export interface SaveDBFileResult {
filePath?: string;
canceled?: boolean;
error?: ErrorMessage;
@@ -122,7 +122,7 @@ export async function saveDBFileAs(
}
}
interface SelectDBFileLocationResult {
export interface SelectDBFileLocationResult {
filePath?: string;
error?: ErrorMessage;
canceled?: boolean;
@@ -154,7 +154,7 @@ export async function selectDBFileLocation(): Promise<SelectDBFileLocationResult
}
}
interface LoadDBFileResult {
export interface LoadDBFileResult {
workspaceId?: string;
error?: ErrorMessage;
canceled?: boolean;
@@ -237,7 +237,7 @@ export async function loadDBFile(): Promise<LoadDBFileResult> {
}
}
interface MoveDBFileResult {
export interface MoveDBFileResult {
filePath?: string;
error?: ErrorMessage;
canceled?: boolean;

View File

@@ -5,7 +5,7 @@ import { logger } from '../logger';
import type { ErrorMessage } from './utils';
import { getFakedResult } from './utils';
interface SavePDFFileResult {
export interface SavePDFFileResult {
filePath?: string;
canceled?: boolean;
error?: ErrorMessage;

View File

@@ -2,9 +2,9 @@ import { BrowserWindow, nativeTheme } from 'electron';
import electronWindowState from 'electron-window-state';
import { join } from 'path';
import { isMacOS, isWindows } from '../../utils';
import { getExposedMeta } from './exposed';
import { logger } from './logger';
import { isMacOS, isWindows } from './utils';
const IS_DEV: boolean =
process.env.NODE_ENV === 'development' && !process.env.CI;

View File

@@ -1,7 +1,7 @@
import { app, BrowserWindow, nativeTheme, session } from 'electron';
import { isMacOS } from '../../../utils';
import type { NamespaceHandlers } from '../type';
import { isMacOS } from '../utils';
import { getMetaData } from './get-meta-data';
import { getGoogleOauthCode } from './google-auth';

View File

@@ -2,8 +2,8 @@ import { app } from 'electron';
import type { AppUpdater } from 'electron-updater';
import { z } from 'zod';
import { isMacOS } from '../../../utils';
import { logger } from '../logger';
import { isMacOS } from '../utils';
import { updaterSubjects } from './event';
export const ReleaseTypeSchema = z.enum([

View File

@@ -2,7 +2,7 @@ import { BehaviorSubject, Subject } from 'rxjs';
import type { MainEventListener } from '../type';
interface UpdateMeta {
export interface UpdateMeta {
version: string;
allowAutoUpdate: boolean;
}

View File

@@ -1,3 +1,11 @@
export function getTime() {
return new Date().getTime();
}
export const isMacOS = () => {
return process.platform === 'darwin';
};
export const isWindows = () => {
return process.platform === 'win32';
};

View File

@@ -3,5 +3,4 @@
interface Window {
apis: typeof import('./src/affine-apis').apis;
events: typeof import('./src/affine-apis').events;
appInfo: typeof import('./src/affine-apis').appInfo;
}

View File

@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-var-requires */
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../../constraints.d.ts" />
// NOTE: we will generate preload types from this file
import { ipcRenderer } from 'electron';
import type { MainIPCEventMap, MainIPCHandlerMap } from '../../constraints';
type WithoutFirstParameter<T> = T extends (_: any, ...args: infer P) => infer R
? (...args: P) => R
: T;

View File

@@ -1,7 +0,0 @@
export const isMacOS = () => {
return process.platform === 'darwin';
};
export const isWindows = () => {
return process.platform === 'win32';
};

View File

@@ -2,7 +2,9 @@
"extends": "../../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"noEmit": true
"noEmit": true,
"target": "ESNext"
},
"references": [{ "path": "../../../tests/kit" }],
"include": ["**.spec.ts", "**.test.ts"]
}

View File

@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"target": "ESNext",
"module": "ESNext",
@@ -12,15 +13,19 @@
"resolveJsonModule": true,
"noImplicitOverride": true
},
"include": ["**/*.ts", "**/*.tsx", "package.json"],
"exclude": ["out", "dist", "node_modules"],
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "out", "dist"],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "../../packages/native"
}
},
{
"path": "../../packages/env"
},
{ "path": "../../tests/kit" }
],
"ts-node": {
"esm": true,

View File

@@ -1,11 +1,13 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": true,
"target": "ESNext",
"module": "ESNext",
"resolveJsonModule": true,
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"noEmit": false
},
"include": ["./scripts", "package.json"]
"include": ["./scripts"]
}