From e3191e520d009e65befb7a9bfeaed6480eef763c Mon Sep 17 00:00:00 2001 From: Kayo Date: Tue, 14 Nov 2023 04:30:35 -0800 Subject: [PATCH] docs(typescript-restrictions): clarify non-jsii deps (#3995) I spent about a day and a half trying to figure this out, so I thought I'd add a little clarification :) tl;dr: I'm making a CDK Construct package that also includes a custom lambda handler. That handler takes on a non-jsii dep but I couldn't figure out why JSII kept trying to compile that non-jsii dep until I read > The API of the *jsii module* can not expose any type from bundled dependencies, since those types would not be available in other languages. about 20 times. --- 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 --- .../user-guides/lib-author/typescript-restrictions.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gh-pages/content/user-guides/lib-author/typescript-restrictions.md b/gh-pages/content/user-guides/lib-author/typescript-restrictions.md index b8a53b83a9..9ab1bc1f22 100644 --- a/gh-pages/content/user-guides/lib-author/typescript-restrictions.md +++ b/gh-pages/content/user-guides/lib-author/typescript-restrictions.md @@ -14,10 +14,14 @@ A *jsii module* can declare dependencies on any other *jsii module* by adding en `package.json` file. Since most other platforms do not support multiple different versions of the same library to coexist in the same closure, it is recommended to also declare all such dependencies as `peerDependencies`. +### non-jsii dependencies + Occasionally, a dependency on a *non-jsii module* is useful. Since such dependencies do not have generated bindings in all the supported languages, they must be bundled with the *jsii module* that depends on them, by adding the library -into the `bundleDependencies` array in `package.json`. The API of the *jsii module* can not expose any type from bundled -dependencies, since those types would not be available in other languages. +into the `bundleDependencies` array in `package.json`. + +The API of the *jsii module* can not expose any type from bundled dependencies, since those types would not be available in other languages. +TypeScript files that include a non-jsii dependency (e.g. a lambda handler for an AWS CDK Construct) cannot be exported from the `main`/`types` entry point. !!! info For more information on `package.json` file contents, refer to the [npm documentation][package-json].