chore(builld): tsconfig project references (#4797)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* chore(builld): tsconfig project references * ci: apply automated fixes * chore(perf-measures): include type-check scripts * chore(perf-measures): install and build ---------
authored by Jonathan Haines · committed by GitHub · parent 8217d9e · Browse files · 24 files·+140 added−77 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Diff stats
24 files+140 added−77 removed
- tests:+22 added−11 removed
- other:+118 added−66 removed
Provenance
- Commit
d69deb8- Tree
d6713b8- Author
Jonathan Haines <jonno.haines@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
8217d9e
24 files changed+140 added−77 removed
modified:.github/actions/perf-measures/action.yml+3 added-1 removed
12 unmodified lines13141516171718192021222342 unmodified lines12 unmodified lines - uses: actions/checkout@v6 - uses: oven-sh/setup-bun@v2 with: bun-version-file: '.tool-versions' - run: | - run: bun install --frozen-lockfile bun install --frozen-lockfile bun tsc --build shell: bash
- name: Performance measurement of type check (tsc) run: |42 unmodified linesadded:perf-measures/type-check/scripts/tsconfig.json+7 added
1234567{ "extends": "../../../tsconfig.base.json", "compilerOptions": { "module": "esnext", "noEmit": true }}modified:perf-measures/type-check/tsconfig.build.json+7 added-4 removed
123235645678910{ "extends": "../tsconfig.json", "include": ["client.ts"], "extends": "../../tsconfig.base.json", "compilerOptions": { "skipLibCheck": true } "noEmit": true }, "exclude": ["dist", "scripts"], "references": [ { "path": "../../tsconfig.build.json" } ]}deleted:perf-measures/tsconfig.json-10 removed
12345678910{ "extends": "../tsconfig.json", "compilerOptions": { "module": "esnext", "noEmit": true, "rootDir": "..", "strict": true }, "include": ["**/*.ts", "**/*.tsx"]}modified:runtime-tests/bun/index.test.tsx+10 added-5 removed
7 unmodified lines8 import { Context } from '../../src/context'9 import { env, getRuntimeKey } from '../../src/helper/adapter'10 import type { WSMessageReceive } from '../../src/helper/websocket'11 import { Hono } from '../../src/index'12-// eslint-disable-next-line @typescript-eslint/no-unused-vars13-import { jsx } from '../../src/jsx'12+import type { PropsWithChildren } from '../../src/jsx'13 import { basicAuth } from '../../src/middleware/basic-auth'14 import { jwt } from '../../src/middleware/jwt'15 16+declare module '../../src/index' {17+ interface ContextRenderer {18+ (content: string | Promise<string>, head: { title: string }): Response | Promise<Response>19+ }20+}21+22 // Test just only minimal patterns.23 // Because others are tested well in Cloudflare Workers environment already.24 25 Bun.env.NAME = 'Bun'179 unmodified lines205 // set "jsxImportSource": "hono/jsx" in the tsconfig.json206 describe('JSX Middleware', () => {207 const app = new Hono()208 204- const Layout = (props: { children?: string }) => {209+ const Layout = (props: PropsWithChildren) => {210 return <html>{props.children}</html>211 }212 213 app.get('/', (c) => {67 unmodified lines281 })282 283 it('Should correctly generate static HTML files for Hono routes', async () => {284 const result = await toSSG(app, { dir: './static' })280- expect(result.success).toBeTruly285+ expect(result.success).toBeTruthy()286 expect(result.error).toBeUndefined()287 expect(result.files).toBeDefined()288 afterAll(async () => {289 await deleteDirectory('./static')37 unmodified lines327 expect(receivedMessage).toBe(message)328 })329 })330 326-async function deleteDirectory(dirPath) {331+async function deleteDirectory(dirPath: string) {332 if (333 await fs334 .stat(dirPath)335 .then((stat) => stat.isDirectory())124 unmodified linesadded:runtime-tests/bun/tsconfig.json+12 added
123456789101112{ "extends": "../../tsconfig.base.json", "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "hono/jsx", "noEmit": true, "types": ["bun-types"] }, "references": [ { "path": "../../tsconfig.build.json" } ]}modified:runtime-tests/fastly/index.test.ts+5 added-1 removed
2 unmodified lines3456789101112131487 unmodified lines1021031041051021061071081092 unmodified linesimport { Hono } from '../../src/index'import { basicAuth } from '../../src/middleware/basic-auth'import { jwt } from '../../src/middleware/jwt'
declare global { var __fastlyComputeNodeDefaultCrypto: boolean | undefined}
beforeAll(() => { vi.stubGlobal('fastly', true) vi.stubGlobal('navigator', undefined)})87 unmodified lines // so following test should run only be polyfill-ed via vite-plugin-fastly-js-compute plugin. // To confirm polyfill-ed or not, check __fastlyComputeNodeDefaultCrypto field is true. it.runIf(!globalThis.__fastlyComputeNodeDefaultCrypto)('Should throw error', () => { expect(() => { app.use('/jwt/*', jwt({ secret: 'secret' })) app.use('/jwt/*', jwt({ alg: 'HS256', secret: 'secret' })) }).toThrow(/`crypto.subtle.importKey` is undefined/) })})added:runtime-tests/fastly/tsconfig.json+10 added
1+{2+ "extends": "../../tsconfig.base.json",3+ "compilerOptions": {4+ "noEmit": true,5+ "types": ["vitest/globals"]6+ },7+ "references": [8+ { "path": "../../tsconfig.build.json" }9+ ]10+}modified:runtime-tests/lambda/index.test.ts+6 added-4 removed
18 unmodified lines19 LatticeRequestContextV2,20 LambdaContext,21 } from '../../src/adapter/aws-lambda/types'22 import { getCookie, setCookie } from '../../src/helper/cookie'23-import { streamSSE } from '../../src/helper/streaming'23+import { streamSSE, streamText } from '../../src/helper/streaming'24 import { Hono } from '../../src/hono'25 import { basicAuth } from '../../src/middleware/basic-auth'26 import './mock'27 894 unmodified lines922 return c.text('Hello Lambda!')923 })924 925 app.get('/stream/text', async (c) => {926- return c.streamText(async (stream) => {926+ return streamText(c, async (stream) => {927 for (let i = 0; i < 3; i++) {928 await stream.writeln(`${i}`)929 await stream.sleep(1)930 }37 unmodified lines968 mockReadableStream.push('2\n')969 mockReadableStream.push('3\n')970 mockReadableStream.push(null) // EOF971 972+ // @ts-expect-error should this be a ReadbleStream?972- await handler(event, mockReadableStream)973+ await handler(event, mockReadableStream, vi.fn())974 975 const chunks = []976 for await (const chunk of mockReadableStream) {977 chunks.push(chunk)35 unmodified lines1013 mockReadableStream.push('data: Message\ndata: It is 0\n\n')1014 mockReadableStream.push('data: Message\ndata: It is 1\n\n')1015 mockReadableStream.push(null) // EOF1016 1017+ // @ts-expect-error should this be a ReadbleStream?1016- await handler(event, mockReadableStream)1018+ await handler(event, mockReadableStream, vi.fn())1019 1020 const chunks = []1021 for await (const chunk of mockReadableStream) {1022 chunks.push(chunk)67 unmodified linesmodified:runtime-tests/lambda/mock.ts+5 added-9 removed
1 import { vi } from 'vitest'2-import type {3- APIGatewayProxyEvent,4- APIGatewayProxyEventV2,5- LambdaFunctionUrlEvent,6-} from '../../src/adapter/aws-lambda/handler'2+import type { LambdaEvent } from '../../src/adapter/aws-lambda/handler'3 import type { LambdaContext } from '../../src/adapter/aws-lambda/types'4 5 type StreamifyResponseHandler = (6 handlerFunc: (11- event: APIGatewayProxyEvent | APIGatewayProxyEventV2 | LambdaFunctionUrlEvent,7+ event: LambdaEvent,8 responseStream: NodeJS.WritableStream,9 context: LambdaContext10 ) => Promise<void>15-) => (event: APIGatewayProxyEvent, context: LambdaContext) => Promise<NodeJS.WritableStream>11+) => (event: LambdaEvent, context: LambdaContext) => Promise<NodeJS.WritableStream>12 13 const mockStreamifyResponse: StreamifyResponseHandler = (handlerFunc) => {14 return async (event, context) => {15 const mockWritableStream: NodeJS.WritableStream = new (require('stream').Writable)({20- write(chunk, _encoding, callback) {16+ write(chunk: Buffer, _encoding: string, callback: () => void) {17 console.log('Writing chunk:', chunk.toString())18 callback()19 },24- final(callback) {20+ final(callback: () => void) {21 console.log('Finalizing stream.')22 callback()23 },24 })14 unmodified linesmodified:runtime-tests/lambda/stream-mock.ts+2 added-1 removed
14 unmodified lines15 ) => (event: APIGatewayProxyEvent, context: LambdaContext) => Promise<NodeJS.WritableStream>16 17 const mockStreamifyResponse: StreamifyResponseHandler = (handlerFunc) => {18 return async (event, context) => {19- const chunks = []19+ const chunks: unknown[] = []20 const mockWritableStream = new Writable({21 write(chunk, _encoding, callback) {22 chunks.push(chunk)23 callback()24 },25 })26+ // @ts-expect-error chunks property for testing27 mockWritableStream.chunks = chunks28 await handlerFunc(event, mockWritableStream, context)29 mockWritableStream.end()30 return mockWritableStream14 unmodified linesmodified:runtime-tests/lambda/stream.test.ts+1 added-1 removed
65 unmodified lines66 isBase64Encoded: false,67 requestContext: testApiGatewayRequestContextV2,68 }69 70- const stream = await handler(event)70+ const stream = await handler(event, {} as LambdaContext, vi.fn())71 72 const metadata = JSON.parse(stream.chunks[0].toString())73 expect(metadata.cookies).toEqual(['cookie1=value1', 'cookie2=value2'])74 })1 unmodified lineadded:runtime-tests/lambda/tsconfig.json+10 added
1+{2+ "extends": "../../tsconfig.base.json",3+ "compilerOptions": {4+ "noEmit": true,5+ "types": ["vitest/globals"]6+ },7+ "references": [8+ { "path": "../../tsconfig.build.json" }9+ ]10+}added:runtime-tests/lambda-edge/tsconfig.json+10 added
1+{2+ "extends": "../../tsconfig.base.json",3+ "compilerOptions": {4+ "noEmit": true,5+ "types": ["vitest/globals"]6+ },7+ "references": [8+ { "path": "../../tsconfig.build.json" }9+ ]10+}added:runtime-tests/node/tsconfig.json+10 added
1+{2+ "extends": "../../tsconfig.base.json",3+ "compilerOptions": {4+ "noEmit": true,5+ "types": ["vitest/globals"]6+ },7+ "references": [8+ { "path": "../../tsconfig.build.json" }9+ ]10+}added:runtime-tests/workerd/tsconfig.json+10 added
1+{2+ "extends": "../../tsconfig.base.json",3+ "compilerOptions": {4+ "noEmit": true,5+ "types": ["vitest/globals"]6+ },7+ "references": [8+ { "path": "../../tsconfig.build.json" }9+ ]10+}deleted:runtime-tests/tsconfig.json-4 removed
1-{2- "extends": "../tsconfig.json",3- "include": ["**/*.ts", "**/*.tsx"]4-}modified:src/adapter/aws-lambda/handler.ts+1 added-6 removed
451 unmodified lines452 .join('&')453 }454 }455 456- protected getCookies(457- // eslint-disable-next-line @typescript-eslint/no-unused-vars458- event: APIGatewayProxyEvent,459- // eslint-disable-next-line @typescript-eslint/no-unused-vars460- headers: Headers461- ): void {456+ protected getCookies(_event: APIGatewayProxyEvent, _headers: Headers): void {457 // nop458 }459 460 protected getHeaders(event: APIGatewayProxyEvent): Headers {215 unmodified linesmodified:src/jsx/types.ts+1 added-2 removed
20 unmodified lines21 props: P22 key: string | null23 }24 type ReactNode = ReactElement | string | number | boolean | null | undefined25-// eslint-disable-next-line @typescript-eslint/no-unused-vars26-type ComponentClass<P = {}, S = {}> = unknown25+type ComponentClass<_P = {}, _S = {}> = unknown26 27 export type { ReactElement, ReactNode, ComponentClass }28 29 export type Event = globalThis.Event11 unmodified linesmodified:bun.lock+3 added
7 unmodified lines8 "@hono/node-server": "^1.13.5",9 "@types/glob": "^9.0.0",10 "@types/jsdom": "^21.1.7",11 "@types/node": "^24.3.0",12+ "@types/ws": "^8.18.1",13 "@typescript/native-preview": "7.0.0-dev.20260210.1",14 "@vitest/coverage-v8": "^3.2.4",15 "arg": "^5.0.2",16 "bun-types": "^1.2.20",436 unmodified lines453 "@types/statuses": ["@types/statuses@2.0.5", "", {}, "sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A=="],454 455 "@types/tough-cookie": ["@types/tough-cookie@4.0.5", "", {}, "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA=="],456 457+ "@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],458+459 "@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.56.1", "", { "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.56.1", "@typescript-eslint/type-utils": "8.56.1", "@typescript-eslint/utils": "8.56.1", "@typescript-eslint/visitor-keys": "8.56.1", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.4.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.56.1", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-Jz9ZztpB37dNC+HU2HI28Bs9QXpzCz+y/twHOwhyrIRdbuVDxSytJNDl6z/aAKlaRIwC7y8wJdkBv7FxYGgi0A=="],460 461 "@typescript-eslint/parser": ["@typescript-eslint/parser@8.56.1", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.56.1", "@typescript-eslint/types": "8.56.1", "@typescript-eslint/typescript-estree": "8.56.1", "@typescript-eslint/visitor-keys": "8.56.1", "debug": "^4.4.3" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-klQbnPAAiGYFyI02+znpBRLyjL4/BrBd0nyWkdC0s/6xFLkXYQ8OoRrSkqacS1ddVxf/LDyODIKbQ5TgKAf/Fg=="],462 1831 unmodified linesmodified:package.json+1 added
659 unmodified lines660 "@hono/node-server": "^1.13.5",661 "@types/glob": "^9.0.0",662 "@types/jsdom": "^21.1.7",663 "@types/node": "^24.3.0",664+ "@types/ws": "^8.18.1",665 "@typescript/native-preview": "7.0.0-dev.20260210.1",666 "@vitest/coverage-v8": "^3.2.4",667 "arg": "^5.0.2",668 "bun-types": "^1.2.20",24 unmodified linesadded:tsconfig.base.json+15 added
1+{2+ "compilerOptions": {3+ "composite": true,4+ "target": "ES2022",5+ "declaration": true,6+ "moduleResolution": "Bundler",7+ "outDir": "${configDir}/dist",8+ "esModuleInterop": true,9+ "forceConsistentCasingInFileNames": true,10+ "strict": true,11+ "skipLibCheck": true,12+ "noUnusedLocals": false,13+ "noUnusedParameters": false14+ }15+}modified:tsconfig.build.json+1 added-1 removed
1 {2- "extends": "./tsconfig.json",2+ "extends": "./tsconfig.base.json",3 "compilerOptions": {4 "module": "ES2020",5 "rootDir": "./src/",6 "outDir": "./dist/types/",17 unmodified linesmodified:tsconfig.json+10 added-28 removed
1 {2- "compilerOptions": {3- "target": "ES2022",4- "declaration": true,5- "moduleResolution": "Bundler",6- "outDir": "./dist",7- "esModuleInterop": true,8- "forceConsistentCasingInFileNames": true,9- "strict": true,10- "skipLibCheck": true,11- "noUnusedLocals": false,12- "noUnusedParameters": false,13- "types": [14- "node",15- "vitest/globals"16- ],17- "jsx": "react",18- "jsxFactory": "jsx",19- "jsxFragmentFactory": "Fragment"20- },21- "include": [22- "src/**/*.ts",23- "src/**/*.d.ts",24- "src/**/*.mts",25- "src/**/*.test.ts",26- "src/**/*.test.tsx"27- ],28- "exclude": [29- "node_modules/*"2+ "files": [],3+ "references": [4+ { "path": "./tsconfig.build.json" },5+ { "path": "./perf-measures/type-check/scripts/tsconfig.json" },6+ { "path": "./runtime-tests/bun/tsconfig.json" },7+ { "path": "./runtime-tests/fastly/tsconfig.json" },8+ { "path": "./runtime-tests/lambda/tsconfig.json" },9+ { "path": "./runtime-tests/lambda-edge/tsconfig.json" },10+ { "path": "./runtime-tests/node/tsconfig.json" },11+ { "path": "./runtime-tests/workerd/tsconfig.json" },12 ]13 }