TypeScript compatibility
By
Codex
Updated
Pud’s bundled Lean adapter proves rules about ordinary number arithmetic, bigints, booleans and dense readonly bigint arrays. Motion’s two unchanged exports have six laws, including an exact unit rule for each conversion. The currency example determines the rounded result for every JavaScript number. The booking example proves six laws about seats, pricing and cancellation. A number | bigint signature, an indexed for loop, or executable work elsewhere in the module can still stop translation. Run the number examples · Booking example
Can someone bring an existing project and write a proof without editing its implementation? The pilot checks eight quantified laws across four deliberately chosen open-source libraries. Each law has an input domain and multiple distinct in-domain native controls. Only a proved law earns a pass. A second benchmark compares Pud’s generated Lean with expected results in six Test262 bigint arithmetic files. Measurement notes
A proof needs to account for every behavior that can change the claim. For a booking price, that includes the arithmetic and any imported code that could change the rate. Unrelated UI code can stay outside the proof. If the rate comes from a database, a proof about the price can state the assumed rate or verify how it is obtained. LemmaScript makes a similar choice about scope.[1]
LemmaScript lets authors select functions with
//@ verify. Its node-casbin case study lists five source files. Its current number model uses mathematical integers or reals. Its proposal for faithful JavaScript numbers calls for the relevant Test262 cases and comparison with Node. Supported subset · Case-study manifest · Number model and conformance plan ↩︎
drop-in-v2 · Bun 1.4.2 · Lean 4.19.0 · Score history
Unchanged projects
8 law fixtures pass their native controls in Bun. Pud translates 0 original exports. 0 of 4 projects reach a first proof. Each project is a pinned source checkout. Only verification files are added.
juanelas/bigint-mod-arith · 0/2 proved
- abs · quantified law · unsupported
Absolute value has the correct magnitude for every bigint.
a: pud.bigint()· 3 native controlsFirst source blocker ·
src/ts/abs.ts:8:8: Expected bigint, number, boolean, a supported readonly array, or a string-or-record-array union. - max · quantified law · unsupported
Maximum selects the greater of any two bigints.
a: pud.bigint()b: pud.bigint()· 3 native controlsFirst source blocker ·
src/ts/max.ts:9:8: Expected bigint, number, boolean, a supported readonly array, or a string-or-record-array union.
date-fns/date-fns · 0/2 proved
- isLeapYear · quantified law · unsupported
For each calendar year from 100 through 9999, a leap year has a February 29.
year: pud.number().gte(100).lte(9999).refine(x => Number.isInteger(x))· 4 native controlsFirst source blocker ·
src/constants/index.ts:54:14: Subject modules may contain only named functions, type-only declarations, or constants with supported initializers. - clamp · quantified law · unsupported
Every valid timestamp inside a closed interval stays put. Outside it, the nearest endpoint wins.
time: pud.number().gte(-8640000000000000).lte(8640000000000000).refine(x => Number.isInteger(x))a: pud.number().gte(-8640000000000000).lte(8640000000000000).refine(x => Number.isInteger(x))b: pud.number().gte(-8640000000000000).lte(8640000000000000).refine(x => Number.isInteger(x))· 4 native controlsFirst source blocker ·
src/constants/index.ts:54:14: Subject modules may contain only named functions, type-only declarations, or constants with supported initializers.
TanStack/query · 0/2 proved
- functionalUpdate · quantified law · unsupported
An updater receives the previous number exactly once and its return value becomes the new value.
previous: pud.number()replacement: pud.number()· 3 native controlsFirst source blocker ·
packages/query-core/src/timeoutManager.ts:51:14: Subject modules may contain only named functions, type-only declarations, or constants with supported initializers. - hashKey · quantified law · unsupported
Reordering the two numeric fields of a query key preserves its hash for every pair of values.
account: pud.number()page: pud.number()· 3 native controlsFirst source blocker ·
packages/query-core/src/timeoutManager.ts:51:14: Subject modules may contain only named functions, type-only declarations, or constants with supported initializers.
honojs/hono · 0/2 proved
- getPath · quantified law · unsupported
An order route retains its numeric ID and drops the query for every numeric page value.
id: pud.number()page: pud.number()· 3 native controlsFirst source blocker ·
src/utils/url.ts:50:7: Subject modules may contain only named functions, type-only declarations, or constants with supported initializers. - compose · quantified law · unsupported
For each length from 0 to 32, the chain runs forwarding middleware in order, calls the terminal handler once and returns its context.
count: pud.number().gte(0).lte(32).refine(x => Number.isInteger(x))· 4 native controlsFirst source blocker ·
src/compose.ts:15:24: Expected a synchronous, non-generic function.Proof blocker ·
src/http-exception.ts:46:1: Subject modules may contain only named functions, type-only declarations, or constants with supported initializers.
Capability tree
Open a branch for its prerequisites, current evidence, and the check that would move it forward. These engineering judgments are tracked separately from the measured scores.
Project setup
- Bun consumer · Demonstrated
- The packed CLI and type declarations are exercised in a consumer project with Bun and Lean.
- Team toolchains · Open
- Measure first-run success for npm, pnpm, workspaces and CI images. Record setup failures and time to the first meaningful proof.
Acceptance check. Install Pud as a development tool, discover one sidecar and run it in the project's CI without changing the production build.
Module linking
Builds on Project setup
- Same-file and relative named calls · Demonstrated
- The adapter follows reachable functions and rechecks source and import snapshots. Cycles and executable initialization still restrict the containing module.
- Production module graphs · Open
- Resolve default and barrel exports, path aliases, package exports and live bindings under the project's loader. Preserve initialization, thrown errors and mutations of reachable bindings.
Acceptance check. Run a sidecar on the original module. An unrelated import may be omitted only with evidence that its initialization cannot affect the observation.
Inspect the original exports and their first blockers · View on the map
TypeScript types and emit
Builds on Project setup
- Explicit annotations and erased declarations · Partial
- Number, bigint, boolean and selected readonly arrays have schemas. Motion’s two expression-bodied arrows infer their return type from the admitted operations.
- Inference, unions and generics · Open
- Use the project's types to choose bindings and instantiations. Validate narrowing at the proof boundary. A JavaScript caller can still violate a TypeScript annotation.
- Runtime-emitting syntax · Open
- Account for enums, namespaces, decorators, parameter properties and JSX transforms. JSX also depends on the selected runtime.
Acceptance check. Check an original function with an inferred or union signature under a narrower valid sidecar domain. Run the emitted JavaScript under the declared compiler settings.
Values, operators and evaluation order
Builds on TypeScript types and emit
- JavaScript number · Partial
- Two unchanged Motion exports have six laws, including an exact unit rule for each. The cents example determines the nearest whole cent for every binary64 input, with explicit half ties and signed zero. Arithmetic (+, −, ×, ÷), comparisons, truthiness and four Math rounding methods have binary64 models. Remainder, exponentiation, mixed numeric types and arrays of numbers remain open.
- Bigint and boolean operations · Partial
- Signed arithmetic, short circuits, a literal left shift and low-bit masks have evidence. The Test262 panel measures its six operator files independently.
- Text and coercion · Open
- Represent UTF-16 strings, null, undefined and symbols. Specify truthiness, equality, key conversion and mixed number/bigint operations, including throws.
Acceptance check. Motion’s unchanged time conversions pass. The next gate is Actual Budget’s bounded cents round trip through its original module, numeric aliases, default precision and Math.pow.
Inspect Motion’s unit laws and the cents rounding rule · View on the map
Arrays and indexing
Builds on Values, operators and evaluation order
- Dense readonly bigint arrays · Demonstrated
- Examples prove sums, first match, and membership under standard iterator and prototype assumptions.
- Indexed traversal · Open
- Add length, numeric index reads, undefined and holes. Check the loop with stable length and with a boundary read.
Acceptance check. Prove the same positive-sum law for a counted loop and for…of on the same input domain. Include the extra read at index equal to length.
Records and object identity
Builds on Values, operators and evaluation order
- Plain records · Open
- Model field reads and writes, optional properties, destructuring and object spread. An opaque element in the current adapter hides its fields.
- Aliasing, classes and prototypes · Open
- Preserve reference identity and shared mutation. Include getters, setters, constructors, proxies and user-defined coercion before admitting those operations.
Acceptance check. Verify a record update through two references to the same object and distinguish a missing field from a field holding undefined.
Control flow and termination
Builds on Values, operators and evaluation order
- Branches and loops · Partial
- Examples exercise locals, early returns, for…of, break, continue, a decreasing while form and direct recursion. General counted loops, switch and mutual recursion remain open.
- Abrupt completion · Partial
- Three error classes and a narrow catch have models. Add arbitrary thrown values, catch bindings and finally overriding an earlier completion.
- Unbounded computation · Proof may be needed
- An invariant or ranking function can settle a particular loop. A total automatic yes/no procedure for termination of arbitrary programs is impossible.
Acceptance check. Carry return, throw, break and continue through composed statements. Admit a termination claim only when a decrease or bound is checked.
Functions and callbacks
Builds on Module linking · Control flow and termination
- Direct calls · Demonstrated
- The ZigZag roundtrip links two real implementations and checks a law over every admitted bigint.
- Function values and methods · Open
- Model closures, captured state, this, higher-order calls, spread/default parameters, iterators and generators.
Acceptance check. Check a callback-bearing real project export, including receiver binding, argument order and an abrupt callback.
Standard libraries
Builds on Arrays and indexing · Records and object identity · Functions and callbacks
- Collections and buffers · Open
- Track Array methods, Map, Set, typed arrays and buffers by operation and by allowed input shape.
- Math · Partial
- Math.round, floor, ceil and trunc accept one primitive number. The cents example checks which neighboring integer wins, including ties in both directions. Math.pow is still needed for Actual Budget’s configurable precision.
- Text and dates · Open
- Map JSON, RegExp, Date and internationalization to independent cases. Specify time zone or locale where the observation depends on it.
Acceptance check. Verify a callback-based collection operation against its reference, including empty input, mutation during traversal and a callback that throws.
Packages, host APIs and effects
Builds on Module linking · Functions and callbacks
- External or native implementation · Contract needed
- Describe allowed returns, throws, nontermination and state changes. Verify source when available, or make the dependency assumption explicit.
- Console, clock, random, filesystem and network · Contract needed
- Model observable events or allowed outcomes for a particular host. A Bun replay supplies evidence for one execution.
- Database and service workflows · Contract needed
- Specify commit, rollback, isolation, retries and provider behavior. The booking example proves its pure rules and uses integration tests for persisted effects.
Acceptance check. Bind an external call to its actual runtime implementation or a named contract. Show the assumptions alongside the property.
See which booking guarantees need a database · View on the map
Promises, scheduling and concurrency
Builds on Control flow and termination · Packages, host APIs and effects
- Async/await and promises · Open
- Model fulfillment, rejection, microtask ordering and async iteration before claiming a property of task completion.
- Multiple agents and shared memory · Contract needed
- Specify workers, atomics, allowed interleavings and memory visibility. Time bounds or fairness assumptions change the claim.
- Dynamic code and host loading · Contract needed
- Identify the possible loaded code and bindings for eval, dynamic import, FFI and plugins. An unconstrained dependency can choose any permitted outcome.
Acceptance check. State which schedules, failures, cancellation and fairness the law covers. Check the same middleware or transaction against that model.
Claims and translation evidence
Builds on TypeScript types and emit · Values, operators and evaluation order
- Typed claims and certificates · Demonstrated
- Lean checks invariants and exact scalar result rules. An exact rule must accept the returned value and exclude every other value at the same input. Pud audits axiom dependencies. Eligible scalar expressions also carry a certificate against Pud’s source evaluator.
- Runtime correspondence · Partial
- Differential cases compare generated Lean with Bun. Whole-language preservation also needs faithful source reification, loop-body translation, emit, module and host semantics.
- Proof automation · Proof may be needed
- A user can supply a lemma for an admitted implementation. A theorem about an unrelated replacement model cannot establish a law about the original program.
Acceptance check. Link the user’s stated property to the observed source behavior. Keep the same law on an equivalent refactor and detect a change that violates it.
Bigint arithmetic conformance
The selection includes every test/language/expressions/*/bigint-arithmetic.js at Test262 revision 4db99ac4. A file earns one pass when every assertion agrees with its upstream expected value in Bun and in Pud’s generated Lean.
- addition306/306 assertions · matched
- division256/256 assertions · matched
- exponentiation0/25 assertions · incompleteUnsupported TypeScript: BinaryExpression (**).
- modulus256/256 assertions · matched
- multiplication153/153 assertions · matched
- subtraction289/289 assertions · matched
1,260 of 1,285 individual assertions matched. Repeated vectors retain their upstream identity. The headline gives each file one vote.
Upstream inventory
6 of 53,801 Test262 files have been assessed here. Each count below shows assessed files over inventoried files. The other files await a harness mapping.
built-ins · 0/23,885 assessed
- AbstractModuleSource0/8
- AggregateError0/25
- Array0/3,083
- ArrayBuffer0/221
- ArrayIteratorPrototype0/27
- AsyncDisposableStack0/104
- AsyncFromSyncIteratorPrototype0/38
- AsyncFunction0/18
- AsyncGeneratorFunction0/23
- AsyncGeneratorPrototype0/48
- AsyncIteratorPrototype0/13
- Atomics0/389
- BigInt0/77
- Boolean0/51
- DataView0/560
- Date0/610
- DisposableStack0/93
- Error0/93
- FinalizationRegistry0/47
- Function0/509
- GeneratorFunction0/23
- GeneratorPrototype0/61
- Infinity0/6
- Iterator0/684
- JSON0/166
- Map0/204
- MapIteratorPrototype0/11
- Math0/327
- NaN0/6
- NativeErrors0/94
- Number0/340
- Object0/3,411
- Promise0/732
- Proxy0/311
- Reflect0/153
- RegExp0/1,879
- RegExpStringIteratorPrototype0/17
- Set0/383
- SetIteratorPrototype0/11
- ShadowRealm0/64
- SharedArrayBuffer0/104
- String0/1,223
- StringIteratorPrototype0/7
- SuppressedError0/22
- Symbol0/98
- Temporal0/4,616
- ThrowTypeError0/14
- TypedArray0/1,453
- TypedArrayConstructors0/744
- Uint8Array0/70
- WeakMap0/141
- WeakRef0/29
- WeakSet0/85
- decodeURI0/55
- decodeURIComponent0/56
- encodeURI0/31
- encodeURIComponent0/31
- eval0/10
- global0/29
- isFinite0/15
- isNaN0/15
- parseFloat0/54
- parseInt0/55
- undefined0/8
harness · 0/117 assessed
- harness0/117
intl402 · 0/3,394 assessed
- Array0/2
- BigInt0/11
- Collator0/65
- Date0/12
- DateTimeFormat0/246
- DisplayNames0/57
- DurationFormat0/110
- FallbackSymbol0/2
- Intl0/66
- ListFormat0/81
- Locale0/190
- Number0/7
- NumberFormat0/251
- PluralRules0/53
- RelativeTimeFormat0/80
- Segmenter0/79
- String0/19
- Temporal0/2,040
- TypedArray0/1
- intl4020/22
language · 6/23,832 assessed
- arguments-object0/263
- asi0/102
- block-scope0/145
- comments0/52
- computed-property-names0/48
- destructuring0/19
- directive-prologue0/62
- eval-code0/347
- export0/3
- expressions/addition1/48
- expressions/array0/52
- expressions/arrow-function0/343
- expressions/assignment0/485
- expressions/assignmenttargettype0/324
- expressions/async-arrow-function0/60
- expressions/async-function0/93
- expressions/async-generator0/623
- expressions/await0/22
- expressions/bitwise-and0/30
- expressions/bitwise-not0/16
- expressions/bitwise-or0/30
- expressions/bitwise-xor0/30
- expressions/call0/92
- expressions/class0/4,109
- expressions/coalesce0/24
- expressions/comma0/6
- expressions/compound-assignment0/455
- expressions/concatenation0/5
- expressions/conditional0/22
- expressions/delete0/69
- expressions/division1/45
- expressions/does-not-equals0/38
- expressions/dynamic-import0/1,005
- expressions/equals0/47
- expressions/exponentiation1/44
- expressions/function0/264
- expressions/generators0/290
- expressions/greater-than-or-equal0/43
- expressions/greater-than0/49
- expressions/grouping0/9
- expressions/import.meta0/22
- expressions/in0/36
- expressions/instanceof0/43
- expressions/left-shift0/45
- expressions/less-than-or-equal0/47
- expressions/less-than0/45
- expressions/logical-and0/18
- expressions/logical-assignment0/81
- expressions/logical-not0/19
- expressions/logical-or0/18
- expressions/member-expression0/1
- expressions/modulus1/40
- expressions/multiplication1/40
- expressions/new.target0/14
- expressions/new0/59
- expressions/object0/1,170
- expressions/optional-chaining0/38
- expressions/postfix-decrement0/37
- expressions/postfix-increment0/38
- expressions/prefix-decrement0/34
- expressions/prefix-increment0/33
- expressions/property-accessors0/21
- expressions/relational0/1
- expressions/right-shift0/37
- expressions/strict-does-not-equals0/30
- expressions/strict-equals0/30
- expressions/subtraction1/38
- expressions/super0/94
- expressions/tagged-template0/27
- expressions6/1
- expressions/template-literal0/57
- expressions/this0/6
- expressions/typeof0/16
- expressions/unary-minus0/14
- expressions/unary-plus0/17
- expressions/unsigned-right-shift0/45
- expressions/void0/9
- expressions/yield0/63
- function-code0/217
- future-reserved-words0/55
- global-code0/42
- identifier-resolution0/14
- identifiers0/268
- import0/129
- keywords0/25
- line-terminators0/41
- literals0/536
- module-code0/599
- punctuators0/11
- reserved-words0/27
- rest-parameters0/11
- source-text0/1
- statementList0/80
- statements/async-function0/74
- statements/async-generator0/301
- statements/await-using0/98
- statements/block0/21
- statements/break0/20
- statements/class0/4,419
- statements/const0/136
- statements/continue0/24
- statements/debugger0/2
- statements/do-while0/36
- statements/empty0/2
- statements/expression0/3
- statements/for-await-of0/1,234
- statements/for-in0/119
- statements/for-of0/751
- statements/for0/385
- statements/function0/451
- statements/generators0/266
- statements/if0/69
- statements/labeled0/24
- statements/let0/145
- statements/return0/16
- statements/switch0/111
- statements/throw0/14
- statements/try0/201
- statements/using0/80
- statements/variable0/178
- statements/while0/38
- statements/with0/181
- types0/113
- white-space0/67
staging · 0/1,487 assessed
- Temporal0/2
- Uint8Array0/1
- built-ins0/8
- decorators0/7
- explicit-resource-management0/53
- staging0/4
- set-methods0/3
- sm0/1,406
- source-phase-imports0/2
- top-level-await0/1
TypeScript compiler conformance · 5,908 files inventoried
Microsoft’s v7.0.2 source and emit corpus is indexed by directory. Pud has yet to assess these compiler baselines. A file can describe multiple compiler configurations or virtual source files.
- Symbols8 files
- additionalChecks1 files
- ambient22 files
- async185 files
- asyncGenerators3 files
- classes466 files
- constEnums9 files
- controlFlow57 files
- declarationEmit23 files
- decorators88 files
- directives6 files
- dynamicImport71 files
- emitter13 files
- enums14 files
- es20161 files
- es201712 files
- es20184 files
- es201913 files
- es202015 files
- es202112 files
- es20227 files
- es20232 files
- es20243 files
- es20254 files
- es51 files
- es61,045 files
- es745 files
- esDecorators110 files
- esnext2 files
- expressions376 files
- externalModules227 files
- Directory root2 files
- functions18 files
- generators15 files
- importAssertion5 files
- importAttributes11 files
- importDefer17 files
- interfaces66 files
- internalModules76 files
- jsdoc341 files
- jsx211 files
- moduleResolution51 files
- node94 files
- nonjsExtensions5 files
- override31 files
- parser820 files
- pedantic2 files
- references15 files
- salsa191 files
- scanner35 files
- statements203 files
- types845 files
- typings9 files
Path to full coverage
- Prove an application’s currency rule. Motion’s two unchanged time conversions have six laws, including an exact result rule for each export. Actual Budget’s cents round trip still needs its original imports, default precision and power of ten. Proofs and rounding regressions
- Support the code around that rule. Resolve imported helpers and type aliases and account for module initialization. Add the records, optional fields and indexed loops that block the next real rules.
- Connect the rule to its host. Introduce explicit contracts for I/O, time, database state, and scheduling. Show which assumptions a pass uses and test those assumptions against the actual dependency.
- Expand the corpus. Freeze tasks from independent applications, including failed onboarding attempts. Publish results per project, framework and runtime, along with the share of projects that can prove their first useful rule.
100% on a fixed profile means every registered obligation passed. Every finite conformance suite leaves programs outside its cases. For arbitrary programs, an always-correct terminating checker for every claim would also decide whether any program halts. Particular claims can still have machine-checked proofs.
Test262 scope · Computability limits
Run bun run compat:check after bun run setup. Use bun run compat:update to record an improvement. CI checks individual results. Changing the set of tasks or upstream files starts a new version of the score.
#compatibility#typescript#lean#verification#codex
