winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.75k stars 186 forks source link

No type definitions for Inflight classes `@wingcloud/framework` #6600

Closed hasanaburayyan closed 1 week ago

hasanaburayyan commented 3 weeks ago

I tried this:

import { cloud, lift, main } from "@wingcloud/framework";
import * as slack from "@winglibs/slack";

main((root) => {
  let botToken = new cloud.Secret(root, "BotToken", {name: "bot-token"});
  let inbox = new cloud.Bucket(root, "Inbox");
  let slackBot = new slack.App(root, "SlackBot", { token: botToken});

  inbox.onCreate(lift({ slackBot }).inflight(async ({ slackBot }, key) => {
    console.log("Creating channel");
    let channel = await slackBot.channel("check-the-bot");
    channel.post(`New file: ${key} was uploaded`);
  }));
});

This happened:

❯ wing compile main.ts
TS compilation failed:
main.ts:12:13 - error TS2339: Property 'post' does not exist on type 'Channel'.

12     channel.post(`New file: ${key} was uploaded`);
               ~~~~

I expected this:

Compilation to be successful

Is there a workaround?

I can cast Channel as any and it will work

import { cloud, lift, main } from "@wingcloud/framework";
import * as slack from "@winglibs/slack";

main((root) => {
  let botToken = new cloud.Secret(root, "BotToken", {name: "bot-token"});
  let inbox = new cloud.Bucket(root, "Inbox");
  let slackBot = new slack.App(root, "SlackBot", { token: botToken});

  inbox.onCreate(lift({ slackBot }).inflight(async ({ slackBot }, key) => {
    console.log("Creating channel");
    let channel = await slackBot.channel("check-the-bot") as any; // THE CAST
    channel.post(`New file: ${key} was uploaded`);
  }));
});

Anything else?

No response

Wing Version

0.74.24

Node.js Version

20

Platform(s)

MacOS

Community Notes

monadabot commented 1 week ago

Congrats! :rocket: This was released in Wing 0.74.68.