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

Commit 9cab9d3

Browse files
authored
Breaking: Remove TypeAnnotation wrapper from constraint (#325)
1 parent b255499 commit 9cab9d3

File tree

5 files changed

+838
-124
lines changed

5 files changed

+838
-124
lines changed

lib/ast-node-types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ module.exports = {
121121
TSNonNullExpression: "TSNonNullExpression",
122122
TSNullKeyword: "TSNullKeyword",
123123
TSNumberKeyword: "TSNumberKeyword",
124+
TSObjectKeyword: "TSObjectKeyword",
124125
TSParameterProperty: "TSParameterProperty",
125126
TSPropertySignature: "TSPropertySignature",
126127
TSQualifiedName: "TSQualifiedName",
@@ -130,6 +131,7 @@ module.exports = {
130131
TSTypePredicate: "TSTypePredicate",
131132
TSTypeReference: "TSTypeReference",
132133
TSUnionType: "TSUnionType",
134+
TSUndefinedKeyword: "TSUndefinedKeyword",
133135
TSVoidKeyword: "TSVoidKeyword",
134136

135137
TypeAnnotation: "TypeAnnotation",

lib/convert.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ module.exports = function convert(config) {
146146
params: typeParameters.map(typeParameter => {
147147
const name = nodeUtils.unescapeIdentifier(typeParameter.name.text);
148148

149+
const constraint = typeParameter.constraint
150+
? convert({ node: typeParameter.constraint, parent: typeParameter, ast, additionalOptions })
151+
: null;
152+
149153
const defaultParameter = typeParameter.default
150154
? convert({ node: typeParameter.default, parent: typeParameter, ast, additionalOptions })
151155
: typeParameter.default;
@@ -158,9 +162,7 @@ module.exports = function convert(config) {
158162
],
159163
loc: nodeUtils.getLoc(typeParameter, ast),
160164
name,
161-
constraint: (typeParameter.constraint)
162-
? convertTypeAnnotation(typeParameter.constraint)
163-
: null,
165+
constraint,
164166
default: defaultParameter
165167
};
166168
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
function f<T extends object = object>() {}

0 commit comments

Comments
 (0)