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 type annotation to main in new project template #4326

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

drewolson
Copy link

@drewolson drewolson commented Mar 10, 2025

This PR adds an annotation of -> Nil to the main function created by the
gleam new command. It also adds the same annotation to the main function in
the generated README.md file.

I've added new snapshot tests for all *.gleam files created in both the erlang
and javascript templates.

Fixes #4313

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.

Thank you. Could you update the changelog also please 🙏

}
});

insta::glob!(&path, "my_project/**/*.gleam", |file_path| {
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, what has this file been changed for?

Copy link
Author

Choose a reason for hiding this comment

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

The existing snapshot tests only test the files at the top-level of the generated project. That means neither src/<my_project>.gleam nor test/<my_project>.gleam had a test around their content. Given that I was updating one of those files, I figured having a snapshot test would be valuable. Let me know if you'd prefer I remove this change.

Copy link
Member

Choose a reason for hiding this comment

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

I see! Could you change the pattern please rather than copying the code twice with 2 different patterns 🙏

Copy link
Author

Choose a reason for hiding this comment

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

Done. Note that I'm excluding hidden directories so that we don't look at contents within .git.

@drewolson drewolson force-pushed the new-project-main-annotation branch from d9ec3ec to 9a35396 Compare March 10, 2025 23:09
@drewolson
Copy link
Author

Thank you. Could you update the changelog also please 🙏

Done.

@drewolson drewolson force-pushed the new-project-main-annotation branch 2 times, most recently from 95a8f4c to 72944dd Compare March 11, 2025 23:09
import gleeunit/should

pub fn main() {
gleeunit.main()
Copy link
Member

Choose a reason for hiding this comment

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

Return annotation on the test main function too please 🙏

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@drewolson drewolson force-pushed the new-project-main-annotation branch from 72944dd to c89844f Compare March 11, 2025 23:12
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.

Add type annotation to main in projects generated by gleam new
2 participants