From 11d91694a3c1109aa4d50b9972ecaaf4a161f317 Mon Sep 17 00:00:00 2001 From: Ika Date: Wed, 27 Jun 2018 21:50:51 +0800 Subject: [PATCH] Breaking: always set optional on ClassProperty (fixes #472) (#491) --- lib/convert.js | 2 +- tests/ast-alignment/fixtures-to-test.js | 2 -- tests/lib/__snapshots__/typescript.js.snap | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/convert.js b/lib/convert.js index f24a91d..5805707 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -860,7 +860,7 @@ module.exports = function convert(config) { } if (node.name.kind === SyntaxKind.Identifier && node.questionToken) { - result.key.optional = true; + result.optional = true; } if (node.exclamationToken) { diff --git a/tests/ast-alignment/fixtures-to-test.js b/tests/ast-alignment/fixtures-to-test.js index c4ba689..9af8d16 100644 --- a/tests/ast-alignment/fixtures-to-test.js +++ b/tests/ast-alignment/fixtures-to-test.js @@ -399,8 +399,6 @@ let fixturePatternConfigsToTest = [ "type-alias-declaration", "type-alias-object-without-annotation", "typed-this", - "class-with-optional-properties", - "class-with-optional-property-undefined", "export-type-function-declaration", "export-type-class-declaration", "abstract-interface", diff --git a/tests/lib/__snapshots__/typescript.js.snap b/tests/lib/__snapshots__/typescript.js.snap index 176b601..9424f52 100644 --- a/tests/lib/__snapshots__/typescript.js.snap +++ b/tests/lib/__snapshots__/typescript.js.snap @@ -13337,7 +13337,6 @@ Object { }, }, "name": "foo", - "optional": true, "range": Array [ 14, 17, @@ -13354,6 +13353,7 @@ Object { "line": 2, }, }, + "optional": true, "range": Array [ 14, 19, @@ -13376,7 +13376,6 @@ Object { }, }, "name": "bar", - "optional": true, "range": Array [ 22, 25, @@ -13393,6 +13392,7 @@ Object { "line": 3, }, }, + "optional": true, "range": Array [ 22, 36, @@ -13450,7 +13450,6 @@ Object { }, }, "name": "baz", - "optional": true, "range": Array [ 47, 50, @@ -13467,6 +13466,7 @@ Object { "line": 4, }, }, + "optional": true, "range": Array [ 39, 61, @@ -13928,7 +13928,6 @@ Object { }, }, "name": "foo", - "optional": true, "range": Array [ 20, 23, @@ -13945,6 +13944,7 @@ Object { "line": 2, }, }, + "optional": true, "range": Array [ 12, 37,