-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsii): unable to use nested types from dependencies (#1866)
Using `--project-references`, nested types from dependencies could not be used as they would result in the following `jsii` error: ``` Type "<type name>" cannot be used as the return type because it is private or @internal ``` This is because in `--project-references` mode, the ambient declaration for the nested type is the declaration that gets resolved to, and those cannot have the `export` keyword: instead, the surrounding module declaration is annotated with `export ambient`. This adds the necessary code path to actually identify this scenario and to appropriately detect the type is actually visible and exported. The check that was failing had been added in #1861 as a way to provide a more helpful error message when private or `@internal` types are mistakenly used on exported APIs; which explains why this situation did not previously occur. > Hidden gem: we were previously adding the `static` keyword when > generating nested classes in **C#**. This is a **Java**-ism and results > in code that won't compile, since **C#** does not allow `static` nested > classes to declare `protected` members (which we actually emit some > of).
- Loading branch information
1 parent
41d79e7
commit 44f9109
Showing
16 changed files
with
19,616 additions
and
20,441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,8 +59,10 @@ jobs: | |
${{ steps.cache-locations.outputs.pip-cache }} | ||
${{ steps.cache-locations.outputs.yarn-cache }} | ||
~/.m2/repository | ||
!~/.m2/repository/software/amazon/jsii/ | ||
~/.nuget/packages | ||
key: ${{ runner.os }}-node@[email protected]${{ hashFiles('**/yarn.lock') }} | ||
!~/.nuget/packages/amazon.jsii.* | ||
key: ${{ runner.os }}-node@[email protected]${{ hashFiles('**/yarn.lock', '**/Directory.Build.targets') }} | ||
restore-keys: |- | ||
${{ runner.os }}-node@[email protected] | ||
${{ runner.os }}-node@12- | ||
|
@@ -130,8 +132,10 @@ jobs: | |
${{ steps.cache-locations.outputs.pip-cache }} | ||
${{ steps.cache-locations.outputs.yarn-cache }} | ||
~/.m2/repository | ||
!~/.m2/repository/software/amazon/jsii/ | ||
~/.nuget/packages | ||
key: ${{ runner.os }}-node@[email protected]${{ hashFiles('**/yarn.lock') }} | ||
!~/.nuget/packages/amazon.jsii.* | ||
key: ${{ runner.os }}-node@[email protected]${{ hashFiles('**/yarn.lock', '**/Directory.Build.targets') }} | ||
restore-keys: |- | ||
${{ runner.os }}-node@[email protected] | ||
${{ runner.os }}-node@12- | ||
|
@@ -276,9 +280,11 @@ jobs: | |
${{ steps.cache-locations.outputs.pip-cache }} | ||
${{ steps.cache-locations.outputs.yarn-cache }} | ||
~/.m2/repository | ||
!~/.m2/repository/software/amazon/jsii/ | ||
~/.nuget/packages | ||
!~/.nuget/packages/amazon.jsii.* | ||
# Not including .NET / Java in the cache keys, those artifacts are SDK-version-independent | ||
key: ${{ runner.os }}-node@${{ matrix.node }}-python@${{ matrix.python }}-${{ hashFiles('**/yarn.lock') }} | ||
key: ${{ runner.os }}-node@${{ matrix.node }}-python@${{ matrix.python }}-${{ hashFiles('**/yarn.lock', '**/Directory.Build.targets') }} | ||
restore-keys: |- | ||
${{ runner.os }}-node@${{ matrix.node }}-python@${{ matrix.python }}- | ||
${{ runner.os }}-node@${{ matrix.node }}- | ||
|
@@ -353,6 +359,10 @@ jobs: | |
# Run the integration test | ||
- name: Install Dependencies | ||
run: |- | ||
# Python tools used during packaging | ||
python3 -m pip install --upgrade pipx setuptools twine wheel | ||
# TypeScript project dependencies | ||
yarn install --frozen-lockfile | ||
working-directory: aws-cdk | ||
- name: Install Tested Packages | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { submodule } from '@scope/jsii-calc-lib'; | ||
|
||
export class NestedClassInstance { | ||
public static makeInstance(): submodule.NestingClass.NestedClass { | ||
return new submodule.NestingClass.NestedClass(); | ||
} | ||
|
||
private constructor() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.