Skip to content

refactor(ts): migrate deserializer to TypeScript with typed distribution - #202

Merged
tvdeyen merged 1 commit into
mainfrom
typescript-pipeline
Aug 31, 2026
Merged

refactor(ts): migrate deserializer to TypeScript with typed distribution#202
tvdeyen merged 1 commit into
mainfrom
typescript-pipeline

Conversation

@tvdeyen

@tvdeyen tvdeyen commented Aug 21, 2026

Copy link
Copy Markdown
Member

Migrates the deserializer to TypeScript and ships type declarations so consumers get types and editor support (including the @deprecated hints on deserializePage/deserializePages added in #201).

Sourcedeserialize, alchemyApiDeserializer and the barrel become .ts. Behaviour is unchanged; the existing specs (migrated to .ts) still pass, and the folded numeric-id/absent-to-many case keeps the coverage the old deserialize.spec.js had.

Distribution pipelinebuild now runs vite build for the JS bundles plus tsc --emitDeclarationOnly for the .d.ts. A tsconfig.json (strict, lib: ["ES2022","DOM"] for structuredClone) drives declaration emit and a new typecheck script. package.json gains a types field and an exports map exposing types for both the root entry and the ./deserialize subpath.

Public type surface — the JSON:API document shapes are kept internal (not exported). deserialize is <T = unknown>(document: unknown): T, so those shapes aren't part of the contract; exporting them would only add generically-named types (JsonApiResource, JsonApiDocument, …) that could collide with a consumer's own definitions. The emitted deserialize.d.ts therefore exposes only deserialize.

Based on main (after #200 and #201).

@tvdeyen
tvdeyen force-pushed the typescript-pipeline branch 3 times, most recently from 69e83bb to 09cae85 Compare August 21, 2026 09:07
Convert the deserializer, alchemyApiDeserializer and barrel to TypeScript
and add a declaration pipeline so consumers get types. The build now runs
vite for the JS bundles plus `tsc --emitDeclarationOnly` for the .d.ts
files, and package exports expose types for both the root entry and the
./deserialize subpath.

The JSON:API document shapes stay internal (not exported): the public
entry point takes `unknown`, so exporting them would only add
generically-named types that could collide in consuming apps. Specs move
to .ts; the single non-redundant case from deserialize.spec.js is folded
into deserialize.spec.ts so no coverage is lost.
@tvdeyen
tvdeyen force-pushed the typescript-pipeline branch 2 times, most recently from 571c3e3 to f2986f1 Compare August 31, 2026 11:50
@tvdeyen
tvdeyen merged commit 3b93397 into main Aug 31, 2026
15 checks passed
@tvdeyen
tvdeyen deleted the typescript-pipeline branch August 31, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant