#Package development issue with Struct extension

9 messages · Page 1 of 1 (latest)

lethal mica
#

Im developing a package using bun but I am encountering issue at build time when I extend Struct :

for example:

export class PublicInput extends Struct({ root: Field, given: Field }) {
  static empty() {
    return new PublicInput({ root: Field(0), given: Field(0) });
  }
}

will return :

The inferred type of 'PublicInput' cannot be named without a reference to '../../../node_modules/o1js/dist/node/lib/field.js'. This is likely not portable. A type annotation is necessary.

https://github.com/iam-robi/ozkarjs/blob/main/src/lib/zkprogram/query.ts#L130

Are we missing some export from o1js or am I missing something ?

GitHub

Contribute to iam-robi/ozkarjs development by creating an account on GitHub.

still acorn
#

The easiest way to get rid of it is to change TypeScript settings or make sure that o1js is not referenced in nested dependencies, only directly.

You can also remove

"declaration": true

or add some strange type declarations to o1js types to make it work (there are examples in issues), or change the package manager.

#

If you will be able to resolve it in some other way by keeping in the same time your settings

  "compilerOptions": {
    // Use ESM
    "module": "NodeNext",
    "moduleResolution": "nodenext",
    "target": "ES2020", 

please let me know; I've found no way to do it, but I would be happy to use such settings in my library. Now I use https://github.com/dfstio/minanft-lib/blob/master/tsconfig.json

lethal mica
#

I have removed declaration : true but it's causing issue when importing the package with bun from my elisa js server 🤔 tricky to get to the right config. I want to get everything working with bun but its been challenging

still acorn
#

If you want to use bun also as a replacement for node, it will probably not work. o1js depends heavily on node features. It is very tricky to get it working on non-node engines like deno.

alpine gazelle
#

I think only Jarred can fix it if he focuses on o1js compatibility. 😄

lethal mica