-
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.
Browse files
Browse the repository at this point in the history
Using the hint allows any interface to always be treated as a struct (as long as all it's properties are readonly and it has no methods) even if it has an `I`-prefixed name.
- Loading branch information
1 parent
ebc6753
commit a4ed9a8
Showing
12 changed files
with
280 additions
and
15 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 |
---|---|---|
|
@@ -5,4 +5,5 @@ nav: | |
- quick-start | ||
- typescript-restrictions.md | ||
- configuration | ||
- hints.md | ||
- 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,27 @@ | ||
# Type system hints | ||
|
||
The `jsii` compiler interprets some documentation tags as hints that influence | ||
the type system represented in the `.jsii` assembly files. | ||
|
||
## Forcing an interface to be considered a *struct* | ||
|
||
Using the `@struct` tag, an interface will be interpreted as a | ||
[*struct*][struct] even if its name starts with a capital `I`, followed by | ||
another capital letter (which normally would make them be treated as | ||
[*behavioral interfaces*][interface]): | ||
|
||
[struct]: ../../specification/2-type-system.md#structs | ||
[interface]: ../../specification/2-type-system.md#behavioral-interfaces | ||
|
||
```ts | ||
/** | ||
* @struct | ||
*/ | ||
export interface IPRange { | ||
readonly cidr: string: | ||
} | ||
``` | ||
|
||
!!! important | ||
The `@struct` hint can only be used on interface declarations. Attempting to | ||
use them on any other declaration will result in a compilation error. |
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.