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

New: Add support for default type parameters (fixes #235) #240

Merged
merged 1 commit into from
Apr 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/ast-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ module.exports = function(ast, extra) {
function convertTSTypeParametersToTypeParametersDeclaration(typeParameters) {
var firstTypeParameter = typeParameters[0];
var lastTypeParameter = typeParameters[typeParameters.length - 1];

return {
type: "TypeParameterDeclaration",
range: [
Expand All @@ -633,6 +634,11 @@ module.exports = function(ast, extra) {
var typeParameterStart = (typeParameter.typeName && typeParameter.typeName.text)
? typeParameter.end - typeParameter.typeName.text.length
: typeParameter.pos;

var defaultParameter = typeParameter.default
? convert(typeParameter.default, typeParameter)
: typeParameter.default;

return {
type: "TypeParameter",
range: [
Expand All @@ -643,7 +649,8 @@ module.exports = function(ast, extra) {
name: typeParameter.name.text,
constraint: (typeParameter.constraint)
? convertTypeAnnotation(typeParameter.constraint)
: null
: null,
default: defaultParameter
};
})
};
Expand Down
Loading