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

Commit 1249aa1

Browse files
committed
Updates per @JamesHenry's code review
1 parent 69d2537 commit 1249aa1

9 files changed

+4133
-2
lines changed

lib/ast-converter.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -1187,10 +1187,27 @@ module.exports = function(ast, extra) {
11871187
id: null,
11881188
params: node.parameters.map(function(param) {
11891189
var convertedParam = convertChild(param);
1190-
convertedParam.decorators = (param.decorators) ? param.decorators.map(function(d) {
1190+
var decorators = (param.decorators) ? param.decorators.map(function(d) {
11911191
return convertChild(d.expression);
11921192
}) : [];
1193-
return convertedParam;
1193+
1194+
if (param.modifiers) {
1195+
return {
1196+
type: "TSParameterProperty",
1197+
range: [param.getStart(), param.end],
1198+
loc: getLoc(param, ast),
1199+
accessibility: getTSNodeAccessibility(param),
1200+
isReadonly: param.modifiers.some(function(modifier) {
1201+
return modifier.kind === SyntaxKind.ReadonlyKeyword;
1202+
}),
1203+
parameter: convertedParam,
1204+
decorators: decorators
1205+
};
1206+
}
1207+
1208+
return assign(convertedParam, {
1209+
decorators: decorators
1210+
});
11941211
}),
11951212
generator: false,
11961213
expression: false,

tests/fixtures/typescript/basics/class-with-private-parameter-properties.result.js

+1,131
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Foo {
2+
constructor(private firstName: string,
3+
private readonly lastName: string,
4+
private age: number = 30,
5+
private readonly student: boolean = false) {}
6+
}

tests/fixtures/typescript/basics/class-with-protected-parameter-properties.result.js

+1,131
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Foo {
2+
constructor(protected firstName: string,
3+
protected readonly lastName: string,
4+
protected age: number = 30,
5+
protected readonly student: boolean = false) {}
6+
}

tests/fixtures/typescript/basics/class-with-public-parameter-properties.result.js

+1,131
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Foo {
2+
constructor(public firstName: string,
3+
public readonly lastName: string,
4+
public age: number = 30,
5+
public readonly student: boolean = false) {}
6+
}

0 commit comments

Comments
 (0)