From 86c522c132a9f3da11afd86092aa8c666f24aece Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Mon, 2 Oct 2017 14:34:10 -0400 Subject: [PATCH] Add type definition for react-truncate (#20181) --- types/react-truncate/index.d.ts | 16 +++++++++++++ types/react-truncate/react-truncate-tests.tsx | 18 +++++++++++++++ types/react-truncate/tsconfig.json | 23 +++++++++++++++++++ types/react-truncate/tslint.json | 1 + 4 files changed, 58 insertions(+) create mode 100644 types/react-truncate/index.d.ts create mode 100644 types/react-truncate/react-truncate-tests.tsx create mode 100644 types/react-truncate/tsconfig.json create mode 100644 types/react-truncate/tslint.json diff --git a/types/react-truncate/index.d.ts b/types/react-truncate/index.d.ts new file mode 100644 index 0000000000..5200016dec --- /dev/null +++ b/types/react-truncate/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for react-truncate 2.1 +// Project: https://github.com/One-com/react-truncate +// Definitions by: Matt Perry +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from 'react'; + +export interface TruncateProps extends React.HTMLProps { + lines?: number | false; + ellipsis?: React.ReactNode; + onTruncate?(isTruncated: boolean): void; +} + +declare class Truncate extends React.Component { } +export default Truncate; diff --git a/types/react-truncate/react-truncate-tests.tsx b/types/react-truncate/react-truncate-tests.tsx new file mode 100644 index 0000000000..c73d5a2ad7 --- /dev/null +++ b/types/react-truncate/react-truncate-tests.tsx @@ -0,0 +1,18 @@ +import * as React from 'react'; +import Truncate from 'react-truncate'; + +const TruncateTest: React.SFC = _ => ( +
+ + Test string + + + isTruncated} className="testClass"> +
Test string
+
+ + Read more} id="identifier"> +
Test string
+
+
+); diff --git a/types/react-truncate/tsconfig.json b/types/react-truncate/tsconfig.json new file mode 100644 index 0000000000..51227d4e80 --- /dev/null +++ b/types/react-truncate/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "jsx": "react", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-truncate-tests.tsx" + ] +} diff --git a/types/react-truncate/tslint.json b/types/react-truncate/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-truncate/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }