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

Add section on JavaScript interop for custom types #272

Merged
merged 3 commits into from
Sep 12, 2023

Conversation

nino
Copy link
Contributor

@nino nino commented Sep 9, 2023

For #200.

Does something like this look reasonable?

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Do you think we should also show them being imported?

// JavaScript
new Guest(); // => {}
new LoggedIn("Kim"); // => { 0: "Kim" }
new Animal("Jinx", 2002); // => { name: "Jinx", cuteness: 2002 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove these comments? They're not accurate, and I think the constructors on the left are clear enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was trying to find a way to explain how to access named and unnamed properties. Maybe we could do something like

const user = new LoggedIn("Kim");
user[0] === "Kim";

const cat = new Cat("Jinx", 2002);
cat.cuteness === 2002;

Not sure if that's overkill

@nino
Copy link
Contributor Author

nino commented Sep 9, 2023

Do you think we should also show them being imported?

That's a good idea actually

@nino nino requested a review from lpil September 9, 2023 17:10
Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful! Thank you

@lpil lpil merged commit 92459d0 into gleam-lang:main Sep 12, 2023
@nino nino deleted the add-js-interop-for-custom-types branch September 12, 2023 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants