-
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.
feat(jsii): experimental --strip-deprecated feature (#2437)
This feature will cause `jsii` to erase all declarations marked with `@deprecated` from the `.jsii` assembly and `.d.ts` files. When a `@deprecated` type is extended (or implemented) by a type that is not `@deprecated`, the inheritance chain will be corrected, erasing the `@deprecated` type and replacing it with it's non `@deprecated` parents, if any. Remaining uses of `@deprecated` members will be reported through diagnostic messages (with the `ERROR` severity). --- A new module `bindings` was implemented to allow relating TypeScript AST nodes to "arbitrary" points in the jsii assembly, allowing to recover that information once the tree was fully processed. This makes multi-pass transformations not need to re-inspect the whole AST again. ---⚠️ This is currently unable to identify interface implementations that become invalid (in the type definitions) as a result of erasing a base class. --- 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
- Loading branch information
1 parent
2630a80
commit f958f5a
Showing
23 changed files
with
1,528 additions
and
120 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 |
---|---|---|
|
@@ -3,4 +3,4 @@ nav: | |
- ... | ||
- user-guides | ||
- specification | ||
- adr | ||
- decisions |
2 changes: 1 addition & 1 deletion
2
gh-pages/content/adr/.pages.yml → gh-pages/content/decisions/.pages.yml
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: Architecture Decision Records | ||
title: Architecture Decisions | ||
order: desc | ||
nav: | ||
- introduction.md | ||
|
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ nav: | |
- quick-start | ||
- typescript-restrictions.md | ||
- configuration | ||
- toolchain |
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,2 @@ | ||
--- | ||
title: Toolchain |
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,80 @@ | ||
# jsii | ||
|
||
The `jsii` tool wraps the standard **TypeScript** compiler, applies the | ||
[TypeScript restrictions](../typescript-restrictions.md), producing additional | ||
diagnostic messages as necessary. | ||
|
||
## Options | ||
|
||
!!! info | ||
This section discusses the main options of `jsii` only. There may be | ||
additional options not mentioned on this page, which can learn about using | ||
`jsii --help`. | ||
|
||
### `--watch` | ||
|
||
The `--watch` option behaves similar to that of the standard **TypeScript** | ||
compiler. It will make `jsii` listen to file changes within the project, and | ||
recompile whenever a source file has changed (including producing diagnostic | ||
messages, and a new `.jsii` assembly file as needed). | ||
|
||
This option is useful when iterating on your code, as it provides a faster | ||
feedback loop than periodically manually re-compiling. | ||
|
||
### `--project-references` | ||
|
||
When `--project-references` is specified, `jsii` will generate a `tsconfig.json` | ||
file that includes `references` to any other local `jsii` project present in the | ||
dependency closure of the current one. | ||
|
||
This option is recommended for any project that is part of a mono-repository, | ||
where multiple `jsii` packages are being maintained. It can result in improved | ||
build times, and a better IDE experience. | ||
|
||
### `--fail-on-warnings` | ||
|
||
The `--fail-on-warnings` option causes compilation top fail if any `warning` | ||
diagnostic is emitted. This setting is recommended for users who want to ensure | ||
the best possible experience for developers using their library in all supported | ||
languages, as it will prevent inadvertent use of one of those languages' | ||
reserved words in an identifier. | ||
|
||
!!! warning | ||
Setting this option might occasionally cause compilation to fail when | ||
performing a minor version upgrade to `jsii`; in particular when support for | ||
a new language is introduced (as this may introduce additional reserved | ||
words, too). | ||
|
||
This situation will be improved in the future, as `jsii` will offer an | ||
option to only warn about reserved words of languages that are configured | ||
for the current project. | ||
|
||
### :test_tube: Experimental Features | ||
|
||
!!! danger | ||
The features discussed in this section are experimental. Their behavior may | ||
change as bugs are addressed, and requirements are clarified through early | ||
adopters. Use at your own risk, and don't forget to [report bugs] you | ||
encounter while doing so! | ||
|
||
[report bugs]: https://github.com/aws/jsii/issues/new/choose | ||
|
||
#### `--strip-dependencies` | ||
|
||
The `--strip-dependencies` option modifies the compilation flow such that all | ||
declarations (types, members) documented with the `@deprecated` tag will be | ||
erased from the visible API of the module: | ||
|
||
- They will be removed from the **TypeScript** declarations (`.d.ts`) files | ||
- They will be removed from the `.jsii` assembly file | ||
- Inheritance chains of non-`@deprecated` types will have their `@deprecated` | ||
bases transitively replaced with non-`@deprecated` bases thereof (or if there | ||
are no such parents, the inheritance relationship will simply be erased) | ||
- Errors will be reported for each remaining use of a `@deprecated` type in the | ||
API (this includes property types, method parameter types, and method return | ||
types) | ||
|
||
However, in order to ensure the underlying code continues to work as designed, | ||
the *implementation* of such declarations will remain in the **JavaScript** | ||
(`.js`) files produced by the compilation. This is, in fact, similar to marking | ||
all `@deprecated` members `@internal`. |
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.