-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
‼️ NOTICE: jsii libraries using v2 (aws-cdk-lib
) require specific import format
#17860
Comments
aws-cdk-lib
)aws-cdk-lib
) require specific import format
Types imported from dependency's submodules are only correctly identified if they are imported via a top-level namespace import. Otherwise, they are incorrectly identified as coming from the top-level scope and compilation will fail. Compare: ```ts // Works import { aws_ec2 as ec2 } from 'aws-cdk-lib'; // Does not work import * as ec2 from 'aws-cdk-lib/aws-ec2'; ``` Fortunately we already have symbol ids to solve this exact issue for Rosetta, so we can resort to looking up FQN by symbol id. Fixes aws/aws-cdk#17860.
Types imported from dependency's submodules are only correctly identified if they are imported via a top-level namespace import. Otherwise, they are incorrectly identified as coming from the top-level scope and compilation will fail. Compare: ```ts // Works import { aws_ec2 as ec2 } from 'aws-cdk-lib'; // Does not work import * as ec2 from 'aws-cdk-lib/aws-ec2'; ``` Fortunately we already have symbol ids to solve this exact issue for Rosetta, so we can resort to looking up FQN by symbol id. Fixes aws/aws-cdk#17860.
Types imported from dependency's submodules are only correctly identified if they are imported via a top-level namespace import. Otherwise, they are incorrectly identified as coming from the top-level scope and compilation will fail. Compare: ```ts // Works import { aws_ec2 as ec2 } from 'aws-cdk-lib'; // Does not work import * as ec2 from 'aws-cdk-lib/aws-ec2'; ``` Fortunately we already have symbol ids to solve this exact issue for Rosetta, so we can resort to looking up FQN by symbol id. Fixes aws/aws-cdk#17860. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
|
I'm getting this error no matter which style I use, so looking forward to a firmer resolution. |
The above proposed solution doesn't work on the use case below. Any ideas?
error JSII3002: Type "aws-cdk-lib.EndpointConfiguration" cannot be used as a return type because it is not exported from aws-cdk-lib 9 public static endpointConfiguration(stack: Stack, group?: string): api.EndpointConfiguration {
627 /**
641 } |
We pinned jsii at 1.47 in our package.json file for the time being, that kept us moving until there's a better solution. |
Have either of ya'll had a chance to see if https://github.com/aws/jsii/releases/tag/v1.49.0 resolves this issue or is it still present? |
Update: This appears to have been fixed in v1.49 for me |
@ldecaro are you still seeing this in 1.48 or later? |
We still see it in 1.49 when building for CDK V2 @aws-solutions-constructs/aws-kinesisstreams-gluejob: lib/index.ts:75:12 - error JSII3002: Type "aws-cdk-lib.CfnTable.ColumnProperty" cannot be used as a list element type because it is not exported from aws-cdk-lib |
@biffgaut I tried reproducing that but seems to work for me. When I did the following:
It seems to work for me:
Code here: rix0rrr/aws-solutions-constructs#1 |
If anyone still has issues with this, can you please make me a repro? |
@rix0rrr I’m not seeing the error described on 1.48. Thanks. |
It cleared up for us when we moved up to building on CDK 2.2.0 (we were several RCs back, I imagine it would have cleared up with 2.1.0 as well) |
I had the same issue with cdk version
After an update to CDK |
|
What is the problem?
Please add your +1 👍 to let us know you have encountered this
Status: IN PROGRESS
Overview
When writing plain TypeScript applications using CDK v2 (
aws-cdk-lib
), you can use one of two different import styles:When writing jsii libraries against CDK v2 (
aws-cdk-lib
), you can currently only use one of those import formats. It must be:If you use the other one, you will see an error like:
Resolution
The issue has been resolved as of jsii
1.48.0
. Make sure you are using that version or higher when writing construct libraries for v2, and you want to use the particular import statement style that doesn't work otherwise.The text was updated successfully, but these errors were encountered: