From bef306b4fca3db24bacc4d81625aeed59f7c0b4a Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Sun, 17 Apr 2022 19:09:28 +0900 Subject: [PATCH] test(typescript-estree): add tests for optional variance syntax --- .../typescript/types/optional-variance-in-and-out.src.ts | 1 + .../typescript/types/optional-variance-in-out.src.ts | 1 + .../fixtures/typescript/types/optional-variance-in.src.ts | 1 + .../typescript/types/optional-variance-out.src.ts | 1 + .../tests/ast-alignment/fixtures-to-test.ts | 8 ++++++++ 5 files changed, 12 insertions(+) create mode 100644 packages/shared-fixtures/fixtures/typescript/types/optional-variance-in-and-out.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/types/optional-variance-in-out.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/types/optional-variance-in.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/types/optional-variance-out.src.ts diff --git a/packages/shared-fixtures/fixtures/typescript/types/optional-variance-in-and-out.src.ts b/packages/shared-fixtures/fixtures/typescript/types/optional-variance-in-and-out.src.ts new file mode 100644 index 000000000000..ee58a11cfc37 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/types/optional-variance-in-and-out.src.ts @@ -0,0 +1 @@ +type Mapper = (x: T) => U; diff --git a/packages/shared-fixtures/fixtures/typescript/types/optional-variance-in-out.src.ts b/packages/shared-fixtures/fixtures/typescript/types/optional-variance-in-out.src.ts new file mode 100644 index 000000000000..1dd6ace1261d --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/types/optional-variance-in-out.src.ts @@ -0,0 +1 @@ +type Processor = (x: T) => T; diff --git a/packages/shared-fixtures/fixtures/typescript/types/optional-variance-in.src.ts b/packages/shared-fixtures/fixtures/typescript/types/optional-variance-in.src.ts new file mode 100644 index 000000000000..3cb911e9c26b --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/types/optional-variance-in.src.ts @@ -0,0 +1 @@ +type Consumer = (x: T) => void; diff --git a/packages/shared-fixtures/fixtures/typescript/types/optional-variance-out.src.ts b/packages/shared-fixtures/fixtures/typescript/types/optional-variance-out.src.ts new file mode 100644 index 000000000000..dd9dd2012492 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/types/optional-variance-out.src.ts @@ -0,0 +1 @@ +type Provider = () => T; diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts index 5c3900f5ba8e..9f1c6c76a800 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -482,6 +482,14 @@ tester.addFixturePatternConfig('typescript/types', { 'template-literal-type-2', 'template-literal-type-3', 'template-literal-type-4', + /** + * [BABEL ERRORED, BUT TS-ESTREE DID NOT] + * Babel doesn't support TS 4.7 new features yet. + */ + 'optional-variance-in', + 'optional-variance-out', + 'optional-variance-in-out', + 'optional-variance-in-and-out', ], });