feat: name every type the public signatures use, before the freeze (CARD-22, D19)
D19 as amended 2026-10-24: nothing that shipped in 26.9.0-beta.2 is removed. Every symbol D19 had listed for removal or review is in that release, so this change only adds exports and marks scope. - Export `AppOptions`, `ExplainNode`, `WsRequest` and `WsSocket`. Each appears in a public signature (`createApp`, `Explain.chain`, `app.upgrade`) but could not be imported. `AppOptions` is the former inline options type of `createApp`, moved verbatim into an interface. - Add `RequestHeaders`. `Headers` shadows the Fetch global wherever it is imported, so it stays only as a `@deprecated` alias of the same type. - Mark the mesh exports and `MeshConfig` `@experimental`. They stay exported and unchanged, but sit outside the freeze, like the `experimental: true` flag the mesh already needs. - The seven review candidates (`withConsoleFallback`, `UNMATCHED_ROUTE`, `HTTP_ERROR`, `VALIDATION_ERROR`, `TransportMismatchError`, `isAsyncIterable`, `buildOpenApi`) stay as they are. CHANGELOG: `### Added` for the types, `### Changed` for the mesh tag, and a new `### Deprecated` for `Headers`. No `### Breaking`. test/types/public-surface.test.ts fails to compile if any of the new names stops being exported. `deno publish --dry-run` passes. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
10 files changed
+113
-16
No files matched your search
@@ -0,0 +1,32 @@
|
||||
// The types D19 added to the barrel (CARD-22): each one appears in a public signature, so a user
|
||||
// must be able to name it. This file's job is to fail to compile if one stops being exported.
|
||||
import { test, expect } from 'vitest';
|
||||
import {
|
||||
createApp,
|
||||
type App,
|
||||
type AppOptions,
|
||||
type ExplainNode,
|
||||
type RequestHeaders,
|
||||
type Headers,
|
||||
type WsRequest,
|
||||
type WsSocket,
|
||||
} from '../../src';
|
||||
|
||||
// Options built apart from the call, the thing an inline type made impossible to annotate.
|
||||
const options: AppOptions = { modules: [] };
|
||||
|
||||
// `app.upgrade(req, socket)`, wrapped by an adapter that has to declare what it passes.
|
||||
const upgrade = (app: App, req: WsRequest, socket: WsSocket) => app.upgrade(req, socket);
|
||||
|
||||
const firstNeeds = (node: ExplainNode): string[] => node.needs;
|
||||
|
||||
// The deprecated alias is the same type, so existing imports keep compiling.
|
||||
const headers: RequestHeaders = { 'x-a': 'b' };
|
||||
const legacy: Headers = headers;
|
||||
|
||||
test('the D19 additions are typeable from the package barrel', () => {
|
||||
expect(typeof createApp(options).fetch).toBe('function');
|
||||
expect(typeof upgrade).toBe('function');
|
||||
expect(firstNeeds({ name: 'n', kind: 'step', origin: 'o', needs: ['a'], provides: [] })).toEqual(['a']);
|
||||
expect(legacy).toBe(headers);
|
||||
});
|
||||
Reference in new issue
Block a user