Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c5e3e1a

Browse files
committedMar 17, 2017
New: Mark optional parameters (fixes #186)
1 parent 215a012 commit c5e3e1a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
 

‎lib/ast-converter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,9 @@ module.exports = function(ast, extra) {
752752
type: "Identifier",
753753
name: ts.unescapeIdentifier(node.text)
754754
});
755+
if (node.parent.questionToken && SyntaxKind.Parameter === node.parent.kind) {
756+
result.optional = true;
757+
}
755758
break;
756759

757760
case SyntaxKind.WithStatement:

‎tests/fixtures/typescript/basics/non-null-assertion-operator.result.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ module.exports = {
7070
}
7171
},
7272
"name": "e",
73+
"optional": true,
7374
"typeAnnotation": {
7475
"type": "TypeAnnotation",
7576
"loc": {
@@ -760,4 +761,4 @@ module.exports = {
760761
}
761762
}
762763
]
763-
};
764+
};

0 commit comments

Comments
 (0)
This repository has been archived.