diff --git a/transforms/__tests__/deprecated-react-child.js b/transforms/__tests__/deprecated-react-child.js index a8dd8447..42765157 100644 --- a/transforms/__tests__/deprecated-react-child.js +++ b/transforms/__tests__/deprecated-react-child.js @@ -10,7 +10,7 @@ function applyTransform(source, options = {}) { { path: "test.d.ts", source: dedent(source), - }, + } ); } @@ -21,7 +21,7 @@ test("not modified", () => { interface Props { children?: ReactNode; } - `), + `) ).toMatchInlineSnapshot(` "import * as React from 'react'; interface Props { @@ -37,7 +37,7 @@ test("named import", () => { interface Props { children?: ReactChild; } - `), + `) ).toMatchInlineSnapshot(` "import { ReactElement } from 'react'; interface Props { @@ -53,7 +53,7 @@ test("named type import", () => { interface Props { children?: ReactChild; } - `), + `) ).toMatchInlineSnapshot(` "import { type ReactElement } from 'react'; interface Props { @@ -69,7 +69,7 @@ test("named type import with existing target import", () => { interface Props { children?: ReactChild; } - `), + `) ).toMatchInlineSnapshot(` "import { ReactElement } from 'react'; interface Props { @@ -85,7 +85,7 @@ test("false-negative named renamed import", () => { interface Props { children?: MyReactChild; } - `), + `) ).toMatchInlineSnapshot(` "import { ReactChild as MyReactChild } from 'react'; interface Props { @@ -101,7 +101,7 @@ test("namespace import", () => { interface Props { children?: React.ReactChild; } - `), + `) ).toMatchInlineSnapshot(` "import * as React from 'react'; interface Props { @@ -115,25 +115,41 @@ test("as type parameter", () => { applyTransform(` import * as React from 'react'; createAction() - `), + `) ).toMatchInlineSnapshot(` "import * as React from 'react'; createAction()" `); }); -test("array syntax", () => { +test("array type syntax", () => { expect( applyTransform(` - import { ReactChild } from 'react'; - interface Props { + import { ReactChild } from 'react'; + interface Props { children?: ReactChild[]; } - `), + `) ).toMatchInlineSnapshot(` "import { ReactElement } from 'react'; interface Props { - children?: (ReactElement | number | string)[]; - }" + children?: (ReactElement | number | string)[]; + }" + `); +}); + +test("Array generic", () => { + expect( + applyTransform(` + import { ReactChild } from 'react'; + interface Props { + children?: Array; + } + `) + ).toMatchInlineSnapshot(` + "import { ReactElement } from 'react'; + interface Props { + children?: Array; + }" `); });