Having Trouble With JS Lib Bindings

Hello! I’m trying to write bindings for the @slack/bolt framework in ReScript and am relatively new to doing bindings for a library. Currently, I’m dealing with defining a function that returns an object that has an ExpressJS.App as a property and getting those bindings to work. I’ve tried numerous things and thought I had it licked, but this is still not working. ReScript doesn’t seem to understand the types

The error is as such:

The record field get can't be found.

If it's defined in another module or file, bring it into scope by:
- Prefixing it with said module name: TheModule.get
- Or specifying its type: let theValue: TheModule.theType = {get: VALUE}

Help would be greatly appreciated! I apologize if this is trivial and if there’s any good learning links you can give me about doing bindings for a library I would greatly appreciate it!

Hey again!

Like the error message says, it can’t find that record field because the record definition isn’t in scope. Try adding an open Express.App before that line, or equivalently (like indicated in the message), expressReciever.app.Express.App.get, which is much more verbose but yeah.

See this record doc section.

1 Like

@chenglou Thank you so much for the quick reply! That worked! Appreciate the link as well, I’m reading up on Records in ReScript as well as the .t module binding pattern.

1 Like

That’s weird, the scope assistance should only be required when passing expressReceiver to a function, where the type isn’t known until it’s used.

In cases like your example the type checker should be able to find that field from the SlackBolt exported types. I use this all the time. The fact that it can find .app but not .app.get is a bit suspicious to me.

Expanding on my example from the other thread:

https://rescript-lang.org/try?code=LYewJgrgNgpgBAZRMGB5ALgCxgJwCoCeADvALxwDeAUHHOsfOnOdbbQOYzoBccAFADoAzuhwBLAHbsAlMwB8cEeKk04AXyoaqoSLDgBRAB5EcMIUIBKMAMYwxAN1zNKq+iTrPWbEyBI56AIy8SpLsADSqtACGRES8SCgY2PgMAuiqGrRu8DDGpuZWtg64AApROFHAnpGKYuwSoQg2pjyKoqEZqgACOtAwfABEXUJQUdYA1gD0AEYgUOgDsl0SMADuqrnouBJRUHDAUeMwvHy5JmaWNnaOOGUVwLKkCkzkA0bnBVfFOANU3UIwCRgDaGLY4HZ7FBYcBBDxPOAQBovOADKGYGG-LSwJimIo3ZzvfKXPG4AQHI58Ci1eqNZpcXgDITIeAA6wtAbqaR-XHXXAAWjkhIuhV5ODJXHRYACfwAUkIBFAQOw+DzvgIfH5AlyqHKFUqVV8bgIYkQBJx0IIUUy0aFFtIgA

1 Like

Thanks for the reply here as well. I’m using the pattern you showed with send now and don’t have this issue. Appreciate you showing that it should work though.

1 Like