Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Winglang bindings for TypeScript packages #7158

Open
Chriscbr opened this issue Sep 23, 2024 · 1 comment
Open

Generate Winglang bindings for TypeScript packages #7158

Chriscbr opened this issue Sep 23, 2024 · 1 comment
Labels
⌨️ cli CLI 🛠️ compiler Compiler ✨ enhancement New feature or request 📐 language-design Language architecture needs-discussion Further discussion is needed prior to impl

Comments

@Chriscbr
Copy link
Contributor

Chriscbr commented Sep 23, 2024

Use Case

As a user, I'd like a way to generate "bindings" so that I can use any TypeScript library from npm (or a local TypeScript package) in my Wing code without needing to write type definitions and extern information by hand. See #4922 for a similar flavor of issue

Proposed Solution

For example, I might be able to run a command:

wing generate --ts @aws-sdk/client-dynamodb

and then a .gen/@aws-sdk/client-dynamodb/ folder would be generated in my current project, with the bindings inside.
The bindings would just be ordinary Wing files using "extern" syntax etc. They're generated by reading the .d.ts files.

Then I can use the library directly in Wing:

bring "./gen/@aws-sdk/client-dynamodb" as dynamo;


inflight () => {
  let client = new dynamo.DynamoDBClient({});
  let putCommand = new dynamo.PutCommand({
    TableName: "my-table"",
    Item: {
      year: { N: 1981 },
      title: { S: "The Evil Dead" },
      info: {
        genres: ["Horror"],
      },
    },
  });
  
  let response = client.send(putCommand);
};

If there's an issue with the bindings that Wing generates, they're all Wing source files, so you can edit them yourself.

Implementation Notes

Some starting constraints to limit the number of ways things can go wrong:

  • mark all functions as inflight to start
  • any types that can't be mapped to Wing will be marked as "any"

Related in spirit to #4922

Component

Language Design, Compiler

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
  • If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Discord.
@Chriscbr Chriscbr added ✨ enhancement New feature or request 📐 language-design Language architecture ⌨️ cli CLI 🛠️ compiler Compiler needs-discussion Further discussion is needed prior to impl labels Sep 23, 2024
@boyney123
Copy link
Contributor

without needing to write type definitions and extern information by hand I'm sold!....

Anyway to simplify the integration with packages out there would. be amazing, the requirement for custom externs I thought was always a bit much.... I love this idea tbh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⌨️ cli CLI 🛠️ compiler Compiler ✨ enhancement New feature or request 📐 language-design Language architecture needs-discussion Further discussion is needed prior to impl
Projects
Status: 🆕 New - not properly defined
Development

No branches or pull requests

2 participants