Handle definite variable declarations (#4025)
* Handle definite variable declarations * printDefinite -> isDefinitemaster
parent
e1491d0f95
commit
b7f0794ad5
|
@ -3204,6 +3204,12 @@ function printTypeAnnotation(path, options, print) {
|
|||
}
|
||||
|
||||
const parentNode = path.getParentNode();
|
||||
const isDefinite =
|
||||
node.definite ||
|
||||
(parentNode &&
|
||||
parentNode.type === "VariableDeclarator" &&
|
||||
parentNode.definite);
|
||||
|
||||
const isFunctionDeclarationIdentifier =
|
||||
parentNode.type === "DeclareFunction" && parentNode.id === node;
|
||||
|
||||
|
@ -3214,7 +3220,7 @@ function printTypeAnnotation(path, options, print) {
|
|||
}
|
||||
|
||||
return concat([
|
||||
isFunctionDeclarationIdentifier ? "" : node.definite ? "!: " : ": ",
|
||||
isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ",
|
||||
path.call(print, "typeAnnotation")
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,17 @@ exports[`definite.ts 1`] = `
|
|||
class MyComponent {
|
||||
ngModel!: ng.INgModelController;
|
||||
}
|
||||
|
||||
const x!: string
|
||||
|
||||
var y!: MyComponent
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class MyComponent {
|
||||
ngModel!: ng.INgModelController;
|
||||
}
|
||||
|
||||
const x!: string;
|
||||
|
||||
var y!: MyComponent;
|
||||
|
||||
`;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
class MyComponent {
|
||||
ngModel!: ng.INgModelController;
|
||||
}
|
||||
|
||||
const x!: string
|
||||
|
||||
var y!: MyComponent
|
||||
|
|
Loading…
Reference in New Issue