acuarica / evm

A Symbolic Ethereum Virtual Machine (EVM) bytecode interpreter, parser and decompiler, along with several other utils for programmatically extracting information from EVM bytecode.
https://acuarica.github.io/evm/
MIT License
46 stars 5 forks source link

TypeScript type declarations for sevm module #51

Closed shazow closed 5 months ago

shazow commented 8 months ago

For v0.5.3: Right now when I try to import in my typescript code, I get this error:

image

Seems related to typescript types not being included.

Not sure why, because I can see the *.d.ts files in the package.

I can still use the imported classes, and I can hide the error with // @ts-ignore but I don't get any type resolving on anything in the package.

acuarica commented 5 months ago

Hi @shazow, this should be fixed in sevm 0.6.7. Essentially the issue was that the (legacy) package entry point was not defined, i.e., the main field was missing in package.json. See 90da9e3d4e99c11fff77e0388b5453a9216fbe5d where it has been fixed.

More specifically, even if the exports fields is defined in package.json, it is not considered when moduleResolution is set to classic.[1, 2] That's the case for files that are outside the TypeScript project's tsconfig.json. What happened is that your PR https://github.com/shazow/whatsabi/pull/62 tsconfig.json excludes the examples folder, thus using classic node resolution there and failing to resolve sevm properly without the legacy main field.

Hope it helps, let me know how it goes.


[1] https://github.com/microsoft/TypeScript/issues/51862#issuecomment-1358049778 [2] https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution

shazow commented 5 months ago

Oh wow thanks for debugging this, that must have been a pain!!