-
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): build succeeds using Omit<T, K> (#1708)
When using the `Omit<T, K>` helper type (a mapped type) on an exported API, `jsii` should detect this and fail, instead of allowing the application to compile. An additional bug caused use of this type to result in a successful exit code from `jsii`, while the `.jsii` file was never written. This was caused by the mapped types symbols not having a `valueDeclaration`, triggering an attempt to read `undefined.parent`, which threw an exception caught by the `Compiler` class, but not signaled back to the caller. Fixes #1707 --- 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
eee8ea5
commit a46fdb1
Showing
6 changed files
with
89 additions
and
2 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
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,11 @@ | ||
///!MATCH_ERROR: Illegal "extends" value for an exported API | ||
|
||
export interface FooBar { | ||
readonly foo: string; | ||
readonly bar: string; | ||
} | ||
|
||
// Illegal attempt to extend Omit<T, Key> | ||
export interface BarBaz extends Omit<FooBar, 'foo'> { | ||
readonly baz: number; | ||
} |
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,12 @@ | ||
///!MATCH_ERROR: Illegal "implements" value for an exported API | ||
|
||
export interface FooBar { | ||
readonly foo: string; | ||
readonly bar: string; | ||
} | ||
|
||
// Illegal attempt to implement Omit<T, Key> | ||
export class BarBaz implements Omit<FooBar, 'foo'> { | ||
public readonly bar = 'BAR!'; | ||
public readonly baz: number = 1337; | ||
} |
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,11 @@ | ||
///!MATCH_ERROR: Only string-indexed map types are supported | ||
|
||
export interface FooBar { | ||
readonly foo: string; | ||
readonly bar: string; | ||
} | ||
|
||
// Illegal attempt to return Omit<T, Key> | ||
export interface IReturner { | ||
bar(): Omit<FooBar, 'foo'>; | ||
} |
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,11 @@ | ||
///!MATCH_ERROR: Only string-indexed map types are supported | ||
|
||
export interface FooBar { | ||
readonly foo: string; | ||
readonly bar: string; | ||
} | ||
|
||
// Illegal attempt to accept Omit<T, Key> | ||
export interface IReturner { | ||
bar(opts: Omit<FooBar, 'foo'>): void; | ||
} |