Support TypeScript
I know this is probably a very complex feature, but I'd like to work with TypeScript when writing functions.
Some stretch goals:
- full integration with VSCode so we no longer have to use the web editor
- add support for testing functions (through CI/CD)
-
spam commented
Bump for this - Is it at all taken into account ?
-
Guillaume MOREL-BAILLY commented
OP created this message more than two years ago. Since then we don't have any news from MongoDB. It is not in their roadmap. To be honest I'm not sure we'll see this feature in 2023...
Therefore on our projects, we are migrating all of our Realm Functions to Azure Functions. It's much better: TypeScript support, local development server, efficient CLI, etc.
-
Rijk commented
Yes please! Having to go to the docs to find out what's in Context or globals like https://www.mongodb.com/docs/atlas/app-services/functions/globals/#std-label-bson feels like going back to 2018
It's relatively easy to set up manual transpilation through a Husky pre-commit hook, but the .ts source file needs to be outside of your realm directory structure otherwise it is cleared later when doing an update from the UI, and you still lack type definitions for the Mongo variables.
Native Typescript support, offering IntelliSense autocompletion and type safety would be a great fit for Atlas Functions as it is usually critical these run safely. It is hard to take Atlas as a platform seriously without it.
-
Alex commented
I do not know if it's appropriate to write here, but still, it might help someone who is looking for a way to develop functions in typescript. I actually went for my approach, which I asked about in the comment below. You may use the CLI build tool made for making functions development easier: https://www.npmjs.com/package/@realm-fun/cli. It is far from delivering the full-fledged typescript support, but it is something / replacement for the time being before Mongo team comes up with their own approach to the issue XD
-
Alex commented
As an alternative, there is a very poor way to transpile a typescript function file to JavaScript, described at "https://dev.to/stasbar/writing-mongo-realm-serverless-functions-in-typescript-5fdo". If typescript support is too much to handle, maybe, someone on your team could try to work out a transpiler for typescript (with imports/exports) etc. to be honest, I tried to write one, but, because of my lack of experience and poor understanding of how Atlas Functions system works, obviously, failed. Maybe something like Wrangler for Cloudflare Workers?
-
James commented
not only typescript support, we need to see which line and function is causing the error.
right now 1 function calling other function does not show which function is causing the error and which line. we dont have stack information, its very very difficult to debug.
plus error logs are limited in length, this is a huge disadvantage when app scale in terms of complexity -
Benjamin commented
Give it to me, baby! TypeScript is awesome and must be supported!
-
Taylor commented
TS support would be great!
(We use github for deploys so we're able to edit/test locally, but some sort of integrated way to simulate function payloads etc locally would be nice.) -
Tender commented
Bump for this - we've got a massive chunk of function code that we'd love to move to realm, but it's all in typescript! Migrating it would be an excessive amount of work right now...