You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The buffer-layout package does not provide types nor does it have types available as @types/buffer-layout in the DefinitelyTyped project. This results in a compilation error when using @blockworks-foundation/mango-client in a TypeScript project with strict compiler settings:
Could not find a declaration file for module 'buffer-layout'. '<my project path>/node_modules/buffer-layout/lib/Layout.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/buffer-layout` if it exists or add a new declaration (.d.ts) file containing `declare module 'buffer-layout';`
import { Blob, Layout, Structure, UInt, Union } from 'buffer-layout';
Adding a declaration declare module 'buffer-layout' like the error suggests leads to other difficult-to-diagnose type errors.
I agree it would be best for Mango packages to start using @solana/buffer-layout too, as more & more packages of the ecosystem start using it, which results in duplicates for consumers, of essentially identical packages.
carnesen
changed the title
Use @solana/buffer-layout instead of regular buffer-layout
Could not find a declaration file for module 'buffer-layout'
Apr 16, 2022
@0xCryptoSheik Thank you, we've incorporated your buffer-layout module definition into our project. This project could think about solving the issue that way too, by shipping your typedef (or similar) with this package. That would be less risky in the sense that it's guaranteed not to change the runtime behavior. I've updated the description of this issue to focus on the problem.
The
buffer-layout
package does not provide types nor does it have types available as@types/buffer-layout
in the DefinitelyTyped project. This results in a compilation error when using@blockworks-foundation/mango-client
in a TypeScript project with strict compiler settings:Adding a declaration
declare module 'buffer-layout'
like the error suggests leads to other difficult-to-diagnose type errors.Thankfully the folks over at Solana Labs have created their own well-typed fork of buffer-layout and are rolling it out into their own published packages.
Could this library switch to using that fork too?
A temporary workaround that worked for me is suggested here: set
"noImplicitAny": false
in tsconfig.json.The text was updated successfully, but these errors were encountered: