Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit a330ec6

Browse files
soda0289JamesHenry
authored andcommitted
New: Add support for default type parameters (fixes #235) (#240)
1 parent e1ef800 commit a330ec6

7 files changed

+1056
-1
lines changed

lib/ast-converter.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ module.exports = function(ast, extra) {
618618
function convertTSTypeParametersToTypeParametersDeclaration(typeParameters) {
619619
var firstTypeParameter = typeParameters[0];
620620
var lastTypeParameter = typeParameters[typeParameters.length - 1];
621+
621622
return {
622623
type: "TypeParameterDeclaration",
623624
range: [
@@ -633,6 +634,11 @@ module.exports = function(ast, extra) {
633634
var typeParameterStart = (typeParameter.typeName && typeParameter.typeName.text)
634635
? typeParameter.end - typeParameter.typeName.text.length
635636
: typeParameter.pos;
637+
638+
var defaultParameter = typeParameter.default
639+
? convert(typeParameter.default, typeParameter)
640+
: typeParameter.default;
641+
636642
return {
637643
type: "TypeParameter",
638644
range: [
@@ -643,7 +649,8 @@ module.exports = function(ast, extra) {
643649
name: typeParameter.name.text,
644650
constraint: (typeParameter.constraint)
645651
? convertTypeAnnotation(typeParameter.constraint)
646-
: null
652+
: null,
653+
default: defaultParameter
647654
};
648655
})
649656
};

0 commit comments

Comments
 (0)