Skip to content

Commit c5e3e1a

Browse files
committed
New: Mark optional parameters (fixes eslint#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

+3
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

+2-1
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)