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

allow TypeScriptIntegration to write prior to the config object literal #1054

Merged
merged 2 commits into from
Oct 24, 2023

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Oct 24, 2023

allow a typescript integration to write content outside of the runtimeConfig object literal as part of the config setup.

@kuhe kuhe requested review from a team as code owners October 24, 2023 18:09
@kuhe kuhe force-pushed the feat/prepareRuntimeConfig branch from 777516b to d15cb5b Compare October 24, 2023 18:10
@kuhe
Copy link
Contributor Author

kuhe commented Oct 24, 2023

  • there are no TS package changes and yarn test passes locally

Comment on lines +178 to +182
writer.onSection("prepareCustomizations", original -> {
for (TypeScriptIntegration integration : integrations) {
integration.prepareCustomizations(writer, target, settings, model);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Not in the scope of this PR, but I feel we should move away from using templates and instead migrate to writers and CodeSections.

By using DirectedCodegen, CodeInterceptors can be used. This would allow state to be accessible to the interceptors (e.g. target) and avoid adding a new integration point in TypeScriptIntegration, e.g.

public record PrepareRuntimeConfigCodeSection(LanguageTarget target) implements CodeSection {}

public final class ExamplePrepareRuntimeConfigCodeInterceptorIntegration implements TypeScriptIntegration {
    @Override
    public List<? extends CodeInterceptor<? extends CodeSection, TypeScriptWriter>> interceptors(
        TypeScriptCodegenContext codegenContext) {
        return List.of(CodeInterceptor.appender(PrepareRuntimeConfigCodeSection.class, (w, s) -> {
            // ...
        }));
    }
}

@kuhe kuhe merged commit 1debb82 into smithy-lang:main Oct 24, 2023
6 of 7 checks passed
@kuhe kuhe deleted the feat/prepareRuntimeConfig branch October 24, 2023 19:39
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.

3 participants