From bd8c74539c87ea4aff0175e1007c671a9813bc26 Mon Sep 17 00:00:00 2001 From: AJ Livingston Date: Wed, 4 Sep 2019 18:53:44 -0400 Subject: [PATCH] adds typings for react-aria-live (#37996) * adds typings for react-aria-live * added typescript version * formatting * fixed lint error * updated return type of LiveMessenger children * formatting --- types/react-aria-live/index.d.ts | 25 ++++++++++++ .../react-aria-live/react-aria-live-tests.tsx | 39 +++++++++++++++++++ types/react-aria-live/tsconfig.json | 25 ++++++++++++ types/react-aria-live/tslint.json | 1 + 4 files changed, 90 insertions(+) create mode 100644 types/react-aria-live/index.d.ts create mode 100644 types/react-aria-live/react-aria-live-tests.tsx create mode 100644 types/react-aria-live/tsconfig.json create mode 100644 types/react-aria-live/tslint.json diff --git a/types/react-aria-live/index.d.ts b/types/react-aria-live/index.d.ts new file mode 100644 index 0000000000..cc5a3108f9 --- /dev/null +++ b/types/react-aria-live/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for react-aria-live 2.0 +// Project: https://github.com/AlmeroSteyn/react-aria-live#readme +// Definitions by: AJ Livingston +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export class LiveAnnouncer extends React.Component { + announcePolite(message: string, id?: string): void; + announceAssertive(message: string, id?: string): void; +} + +export const LiveMessage: React.StatelessComponent<{ + 'aria-live': 'assertive' | 'polite'; + clearOnUnmount?: boolean | 'true' | 'false'; + message: string; +}>; + +export const LiveMessenger: React.StatelessComponent<{ + children(contextProps: { + announceAssertive(message: string, id?: string): void; + announcePolite(message: string, id?: string): void; + }): React.ReactNode; +}>; diff --git a/types/react-aria-live/react-aria-live-tests.tsx b/types/react-aria-live/react-aria-live-tests.tsx new file mode 100644 index 0000000000..0e4abf0299 --- /dev/null +++ b/types/react-aria-live/react-aria-live-tests.tsx @@ -0,0 +1,39 @@ +import * as React from 'react'; +import { render } from 'react-dom'; + +import { LiveAnnouncer, LiveMessage, LiveMessenger } from 'react-aria-live'; + +render( + + + , + document.getElementById('main') +); + +render( + + + {({ announcePolite, announceAssertive }) => + <> + + + + } + + , + document.getElementById('main') +); diff --git a/types/react-aria-live/tsconfig.json b/types/react-aria-live/tsconfig.json new file mode 100644 index 0000000000..9341e4979c --- /dev/null +++ b/types/react-aria-live/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-aria-live-tests.tsx" + ] +} diff --git a/types/react-aria-live/tslint.json b/types/react-aria-live/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-aria-live/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }