-
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): TypeError: Cannot read property 'getJsDocTags' of undefined (
#2163) When a trailing semicolon was left after a method body, the compiler would choke with a `TypeError` due to attempting to read the JSDoc tags of an `undefined` symbol. This checks for this particular case and ignores the "class member" that is represented by the dangling semicolon; and emits a diagnostic message informing users the token could be removed. Fixes #2098 --- 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
ce7599f
commit 5d87101
Showing
5 changed files
with
63 additions
and
7 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
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,32 @@ | ||
import { sourceToAssemblyHelper } from '../lib'; | ||
|
||
// ---------------------------------------------------------------------- | ||
test('trailing semicolon after method is correctly ignored', async () => { | ||
const assembly = await sourceToAssemblyHelper(` | ||
export class Foo { | ||
private readonly initialized: boolean; | ||
public constructor() { | ||
this.initialized = true; | ||
}; | ||
public method() { return this.initialized; }; | ||
} | ||
`); | ||
|
||
expect(assembly.types!['testpkg.Foo']).toEqual({ | ||
assembly: 'testpkg', | ||
fqn: 'testpkg.Foo', | ||
kind: 'class', | ||
methods: [ | ||
{ | ||
locationInModule: { filename: 'index.ts', line: 9 }, | ||
name: 'method', | ||
returns: { type: { primitive: 'boolean' } }, | ||
}, | ||
], | ||
initializer: { locationInModule: { filename: 'index.ts', line: 5 } }, | ||
locationInModule: { filename: 'index.ts', line: 2 }, | ||
name: 'Foo', | ||
}); | ||
}); |