fix: type check (#70)

This commit is contained in:
Alex Yang
2025-04-22 23:23:07 -07:00
committed by GitHub
parent d38cd81f05
commit 886f3ffb23
7 changed files with 33 additions and 34 deletions
+17
View File
@@ -68,3 +68,20 @@ jobs:
run: pnpm install
- name: Run lint
run: pnpm run lint
type:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Run build
run: pnpx turbo run build --filter="./packages/*"
- name: Run type check
run: pnpm run typecheck
+3 -23
View File
@@ -1,7 +1,7 @@
import { type WorkflowEvent, type WorkflowEventData } from "./event";
import { createContext, type Handler, type WorkflowContext } from "./context";
export type Workflow<Mis extends [] = [], Mos extends [] = []> = {
export type Workflow = {
handle<
const AcceptEvents extends WorkflowEvent<any>[],
Result extends ReturnType<WorkflowEvent<any>["with"]> | void,
@@ -9,30 +9,10 @@ export type Workflow<Mis extends [] = [], Mos extends [] = []> = {
accept: AcceptEvents,
handler: Handler<AcceptEvents, Result>,
): void;
createContext(): Mutate<WorkflowContext, Mis>;
$$workflowMutators?: Mos;
createContext(): WorkflowContext;
};
type Mutate<S, Ms> = number extends Ms["length" & keyof Ms]
? S
: Ms extends []
? S
: Ms extends [[infer Mi, infer Ma], ...infer Mrs]
? Mutate<WorkflowMutators<S, Ma>[Mi & WorkflowMutatorIdentifier], Mrs>
: never;
export interface WorkflowMutators<S, A> {}
export type WorkflowMutatorIdentifier = keyof WorkflowMutators<
unknown,
unknown
>;
export type WorkflowCreator<
Mis extends [] = [],
Mos extends [] = [],
> = () => Workflow<Mis, Mos>;
export const createWorkflow: WorkflowCreator = (): Workflow => {
export const createWorkflow = (): Workflow => {
const config = {
steps: new Map<
WorkflowEvent<any>[],
+2 -2
View File
@@ -6,7 +6,7 @@ import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/proto
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
const requestHandlerExtraAsyncLocalStorage =
createAsyncContext<RequestHandlerExtra>();
createAsyncContext<RequestHandlerExtra<any, any>>();
export const getReqHandlerExtra = () => {
const extra = requestHandlerExtraAsyncLocalStorage.getStore();
@@ -26,7 +26,7 @@ export function mcpTool<
stop: WorkflowEvent<Stop>,
): (
args: Start,
extra: RequestHandlerExtra,
extra: RequestHandlerExtra<any, any>,
) => CallToolResult | Promise<CallToolResult> {
return async (args, extra) =>
requestHandlerExtraAsyncLocalStorage.run(extra, async () => {
+1 -1
View File
@@ -7,7 +7,7 @@
"include": ["./src"],
"references": [
{
"path": "./tsconfig.test.json"
"path": "../core/tsconfig.json"
}
]
}
+6 -1
View File
@@ -4,5 +4,10 @@
"outDir": "./lib/test/browser",
"tsBuildInfoFile": "./lib/test/.tsbuildinfo"
},
"include": ["./src", "./tests", "./vitest.config.ts"]
"include": ["./tests", "./vitest.config.ts"],
"references": [
{
"path": "./tsconfig.json"
}
]
}
+3 -6
View File
@@ -25,17 +25,14 @@
{
"path": "./packages/core/tsconfig.test.json"
},
{
"path": "./packages/core/tsconfig.browser.test.json"
},
{
"path": "./packages/core/tsconfig.browser.json"
},
{
"path": "./packages/core/tsconfig.json"
},
{
"path": "./packages/llamaindex/tsconfig.json"
},
{
"path": "./packages/llamaindex/tsconfig.test.json"
}
]
}
+1 -1
View File
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./lib/lint-staged",
"tsBuildInfoFile": "./lib/lint-staged/.tsbuildinfo",