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

feat(rosetta): hoist declare statements to top-level of document #2897

Merged
merged 4 commits into from
Jul 21, 2021

Conversation

BenChaimberg
Copy link
Contributor

declare statements allow snippet writers to create a mock variable of a certain type that can be used within a snippet without having to provide a concrete value of that type. This is useful when referencing a type from another module without needing to create an instance of that type, which may be complex. Example:

declare const lambdaFunction: lambda.Function;
const myResource = ...
myResource.grantRead(lambdaFunction);

declare statements can only exist at the top level of a document, meaning snippets with fixtures may not be able to define a declare statement, since the snippet may be embedded into the fixture within a class, function, etc. This feature "hoists" declare statements to the top level of the document, similarly to how import statements are hoisted currently.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 1, 2021
@BenChaimberg BenChaimberg requested review from RomainMuller and a team July 1, 2021 20:28
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Cool stuff

Copy link
Contributor

@RomainMuller RomainMuller 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 so much!

@mergify
Copy link
Contributor

mergify bot commented Jul 21, 2021

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Jul 21, 2021
@RomainMuller RomainMuller merged commit 7b2ec05 into main Jul 21, 2021
@RomainMuller RomainMuller deleted the chaimber/hoist_declare branch July 21, 2021 16:01
@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants