-
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 return Promise<void> (#3752)
The void-check only accounted for the literal `void` type, but failed to account for the `Promise<void>` case. This is now fixed. Fixes #51 --- 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
1cffb04
commit 852b3dc
Showing
3 changed files
with
65 additions
and
6 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
import { sourceToAssemblyHelper } from '../lib'; | ||
|
||
// ---------------------------------------------------------------------- | ||
test('Promise<void> is a valid return type', () => { | ||
const assembly = sourceToAssemblyHelper(` | ||
export class PromiseMaker { | ||
public static staticPromise(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
public instancePromise(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
private constructor() {} | ||
} | ||
`); | ||
|
||
expect(assembly.types!['testpkg.PromiseMaker']).toEqual({ | ||
assembly: 'testpkg', | ||
fqn: 'testpkg.PromiseMaker', | ||
kind: 'class', | ||
methods: [ | ||
{ | ||
async: true, | ||
locationInModule: { filename: 'index.ts', line: 3 }, | ||
name: 'staticPromise', | ||
static: true, | ||
}, | ||
{ | ||
async: true, | ||
locationInModule: { filename: 'index.ts', line: 7 }, | ||
name: 'instancePromise', | ||
}, | ||
], | ||
locationInModule: { filename: 'index.ts', line: 2 }, | ||
name: 'PromiseMaker', | ||
symbolId: 'index:PromiseMaker', | ||
}); | ||
}); |