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

fix: generated examples fail when scope is not of type Construct #262

Merged
merged 2 commits into from
Jun 1, 2023

Conversation

kaizencc
Copy link
Contributor

In the generated fixture, this is of type construct:

import { Construct } from "constructs";
class MyConstruct extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
/// here
} }

Therefore we can only supply this when the type is the same. Notably, the generated examples fail when the type is an App:

@aws-cdk.app-staging-synthesizer-alpha.DefaultStagingStack-example.ts:20:83 - error TS2345: Argument of type 'this' is not assignable to parameter of type 'App'.

const defaultStagingStack = new app_staging_synthesizer_alpha.DefaultStagingStack(this, 'MyDefaultStagingStack', {

@@ -93,7 +93,7 @@ describe('generateClassAssignment ', () => {
'declare const prop5: any;',
'declare const property: my_assembly.Property;',
'',
'const classA = new my_assembly.ClassA(this, \'MyClassA\', {',
'const classA = new my_assembly.ClassA(\'scope\', \'MyClassA\', {',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this has to happen. i could not find a good way of mocking the constructs.Construct fqn and spent far too much time trying to figure it out.

@mergify mergify bot merged commit 90ebdcc into main Jun 1, 2023
@mergify mergify bot deleted the conroy/bugfix branch June 1, 2023 11:19
mergify bot pushed a commit to aws/aws-cdk that referenced this pull request Jun 2, 2023
…version (#25815)

Includes cdklabs/cdk-generate-synthetic-examples#262

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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