Skip to content

Commit

Permalink
Fix: Missing parameter properties info in constructors (fixes eslint#143
Browse files Browse the repository at this point in the history
)
  • Loading branch information
weirdpattern committed Feb 27, 2017
1 parent 69d2537 commit 6b38526
Show file tree
Hide file tree
Showing 9 changed files with 4,133 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/ast-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1187,10 +1187,27 @@ module.exports = function(ast, extra) {
id: null,
params: node.parameters.map(function(param) {
var convertedParam = convertChild(param);
convertedParam.decorators = (param.decorators) ? param.decorators.map(function(d) {
var decorators = (param.decorators) ? param.decorators.map(function(d) {
return convertChild(d.expression);
}) : [];
return convertedParam;

if (param.modifiers) {
return {
type: "TSParameterProperty",
range: [param.getStart(), param.end],
loc: getLoc(param, ast),
accessibility: getTSNodeAccessibility(param),
isReadonly: param.modifiers.filter(function(modifier) {
return modifier.kind === SyntaxKind.ReadonlyKeyword;
}).length > 0,
parameter: convertedParam,
decorators: decorators
};
}

return assign(convertedParam, {
decorators: decorators
});
}),
generator: false,
expression: false,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Foo {
constructor(private firstName: string,
private readonly lastName: string,
private age: number = 30,
private readonly student: boolean = false) {}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Foo {
constructor(protected firstName: string,
protected readonly lastName: string,
protected age: number = 30,
protected readonly student: boolean = false) {}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Foo {
constructor(public firstName: string,
public readonly lastName: string,
public age: number = 30,
public readonly student: boolean = false) {}
}
Loading

0 comments on commit 6b38526

Please sign in to comment.