Typescript and collections

Hello, trying to convert my project to typescript i get this error

Module '"../node_modules/@types/forest-express-sequelize"' has no exported member 'collection'

for this code

import { collection } from 'forest-express-sequelize';

but this

const { collection } = require('forest-express-sequelize');

transpile fine

Hello !
Did you follow this documentation ?

Hi @Nicolas_Sailly, thanks for helping.

Yes.

I have translated all my models to typescript and it works fine.

Hi @Nicolas_Sailly sorry for delay i made a little video to show you the problem.

Hi @Benjamin_Marquis,

Thanks for sharing this video :ok_hand:

Is this error avoiding your admin backend to work well or is it only a code editor error?

Hello @adriguy, thanks for helping sorry i was unavailable the last days , it create a typescript compilation error

Hello @Benjamin_Marquis :wave:

Thanks for opening a thread, Iā€™m glad you are trying our typescript integration :tada:

Indeed, I checked the types and the collection object is missing from them. We will add it ASAP and I will keep you in touch when the new types are ready.

As you pointed out, using require (which is not type checked by typescript) is the workaround here.

If I may, I will ping you back in this thread to confirm with you that new types are working.

Thanks again for the feedback,

Steve.

3 Likes

HI @Steve_Bunlon, perfect, thanks for your help!

1 Like

Hello @Benjamin_Marquis :wave:

We have updated our types on forest-express-sequelize. You should now see some types completion/suggestion while using the collection function from forest :raised_hands: You can run the following to upgrade:

npm install @types/forest-express-sequelize@latest

Also you can add back the following statement to import collection without any transpilation error:

import { collection } from 'forest-express-sequelize';

If you encounter any other problem using our typescript integration, please do not hesitate :+1:

Thanks for the thread :smiley:

Steve.

4 Likes

Very nice, thanks a lot!
Great work :muscle:t2:

1 Like