Skip to content

Commit

Permalink
Fix that comments of variable declaration are not emitted; Bump self …
Browse files Browse the repository at this point in the history
…to 1.2.2
  • Loading branch information
shrinktofit committed Dec 11, 2019
1 parent 270a37c commit 55fa369
Show file tree
Hide file tree
Showing 5 changed files with 413 additions and 5 deletions.
8 changes: 7 additions & 1 deletion build/gift.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/gift.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tfig",
"version": "1.2.1",
"version": "1.2.2",
"description": "Yet another tool to generate .d.ts bundle.",
"main": "build/gift.js",
"types": "build/gift.d.ts",
Expand Down
10 changes: 8 additions & 2 deletions source/gift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,15 @@ class BundleGenerator {
return result;
}

private _copyComments<T extends ts.Node>(src: ts.Node, dst: T) {
private _copyComments<T extends ts.Node>(src: ts.Node, dst: T): T {
if (ts.isVariableDeclaration(src) &&
ts.isVariableDeclarationList(src.parent) &&
ts.isVariableStatement(src.parent.parent)) {
// https://github.com/microsoft/TypeScript/issues/35620
return this._copyComments(src.parent.parent, dst);
}
const sourceFileText = src.getSourceFile().text;
ts.forEachLeadingCommentRange(sourceFileText, src.getFullStart(), (pos, end, kind) => {
ts.forEachLeadingCommentRange(sourceFileText, src.pos, (pos, end, kind) => {
let tex = sourceFileText.substring(pos, end);
if (tex.startsWith('/*')) {
tex = tex.substr(2, tex.length - 4);
Expand Down
Loading

0 comments on commit 55fa369

Please sign in to comment.