Skip to content

Typescript typedef and doc fixes#8073

Merged
NikolajBjorner merged 2 commits intoZ3Prover:masterfrom
Macil:fixCtor
Dec 15, 2025
Merged

Typescript typedef and doc fixes#8073
NikolajBjorner merged 2 commits intoZ3Prover:masterfrom
Macil:fixCtor

Conversation

@Macil
Copy link
Copy Markdown
Contributor

@Macil Macil commented Dec 13, 2025

The first example in the npm docs suggest that you can use Z3 in Node like this:

const { init } = require('z3-solver');
const { Context } = await init();
const { Solver, Int, And } = new Context('main');

but if you use Typescript, that code gives a type error:

z3testnode.ts:3:30 - error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.

3 const { Solver, Int, And } = new Context("main");
                               ~~~~~~~~~~~~~~~~~~~


Found 1 error in z3testnode.ts:3

and you're forced to rewrite the code to be this instead:

const { Solver, Int, And } = Context('main');

This PR fixes the type definitions so Typescript allows new Context to be used, consistent with the examples.


Second, this PR fixes a tsdoc example which used a nonexistent sat import instead of the string "sat".

Loading
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.

2 participants