From c10ef267d3cd8ea130786dba8f8fb9dc3c7e90f9 Mon Sep 17 00:00:00 2001 From: LittleB <1317697565@qq.com> Date: Tue, 3 Dec 2019 04:38:52 +0800 Subject: [PATCH] add @types/react-stars (#40725) --- types/react-stars/index.d.ts | 43 +++++++++++++++++++++++++ types/react-stars/react-stars-tests.tsx | 17 ++++++++++ types/react-stars/tsconfig.json | 25 ++++++++++++++ types/react-stars/tslint.json | 1 + 4 files changed, 86 insertions(+) create mode 100644 types/react-stars/index.d.ts create mode 100644 types/react-stars/react-stars-tests.tsx create mode 100644 types/react-stars/tsconfig.json create mode 100644 types/react-stars/tslint.json diff --git a/types/react-stars/index.d.ts b/types/react-stars/index.d.ts new file mode 100644 index 0000000000..77a329de65 --- /dev/null +++ b/types/react-stars/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for react-stars 2.2 +// Project: https://github.com/n49/react-stars +// Definitions by: TingYuLC +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.6 + +import * as React from "react"; + +interface ReactStarsProps { + /** Name of parent class */ + className?: string; + + /** How many total stars you want */ + count?: number; + + /** Set rating value */ + value?: number; + + /** Which character you want to use as a star */ + char?: string; + + /** Color of inactive star (this supports any CSS valid value) */ + color1?: string; + + /** Color of selected or active star */ + color2?: string; + + /** Size of stars (in px) */ + size?: number; + + /** Should you be able to select rating or just see rating (for reusability) */ + edit?: boolean; + + /** Should component use half stars, if not the decimal part will be dropped otherwise normal algebra rools will apply to round to half stars */ + half?: boolean; + + /** Will be invoked any time the rating is changed */ + onChange?: (new_rating: number) => void; +} + +declare class ReactStars extends React.Component {} + +export default ReactStars; diff --git a/types/react-stars/react-stars-tests.tsx b/types/react-stars/react-stars-tests.tsx new file mode 100644 index 0000000000..cc45c8645f --- /dev/null +++ b/types/react-stars/react-stars-tests.tsx @@ -0,0 +1,17 @@ +import ReactStars from "react-stars"; +import * as React from "react"; + +const starsChange = (newVal: number) => {}; + +const Stars: JSX.Element = ( + +); diff --git a/types/react-stars/tsconfig.json b/types/react-stars/tsconfig.json new file mode 100644 index 0000000000..7b46864b3f --- /dev/null +++ b/types/react-stars/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "esModuleInterop": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "jsx": "react", + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-stars-tests.tsx" + ] +} diff --git a/types/react-stars/tslint.json b/types/react-stars/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-stars/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }