From 08c29b69ff9d4566aaa2b4e1186ce47c7fe95504 Mon Sep 17 00:00:00 2001 From: Zhang Yi Jiang Date: Thu, 14 Feb 2019 11:50:09 +0800 Subject: [PATCH] Add react-kawaii typings --- types/react-kawaii/index.d.ts | 33 +++++++++++++++++++++++ types/react-kawaii/react-kawaii-tests.tsx | 22 +++++++++++++++ types/react-kawaii/tsconfig.json | 24 +++++++++++++++++ types/react-kawaii/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/react-kawaii/index.d.ts create mode 100644 types/react-kawaii/react-kawaii-tests.tsx create mode 100644 types/react-kawaii/tsconfig.json create mode 100644 types/react-kawaii/tslint.json diff --git a/types/react-kawaii/index.d.ts b/types/react-kawaii/index.d.ts new file mode 100644 index 0000000000..59a311c091 --- /dev/null +++ b/types/react-kawaii/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for react-kawaii 0.11 +// Project: https://github.com/miukimiu/react-kawaii +// Definitions by: Zhang Yi Jiang +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export type KawaiiMood = + | 'sad' + | 'shocked' + | 'happy' + | 'blissful' + | 'lovestruck' + | 'excited' + | 'ko'; + +export interface KawaiiProps { + size?: number; + color?: string; + mood?: KawaiiMood; +} + +export const SpeechBubble: React.ComponentType; +export const Mug: React.ComponentType; +export const Browser: React.ComponentType; +export const Ghost: React.ComponentType; +export const Cat: React.ComponentType; +export const IceCream: React.ComponentType; +export const CreditCard: React.ComponentType; +export const File: React.ComponentType; +export const Backpack: React.ComponentType; +export const Planet: React.ComponentType; diff --git a/types/react-kawaii/react-kawaii-tests.tsx b/types/react-kawaii/react-kawaii-tests.tsx new file mode 100644 index 0000000000..d8412e3dbf --- /dev/null +++ b/types/react-kawaii/react-kawaii-tests.tsx @@ -0,0 +1,22 @@ +import * as React from 'react'; +import { Cat, Planet, Mug, Browser, Backpack, Ghost, File, SpeechBubble, KawaiiMood, KawaiiProps, IceCream } from 'react-kawaii'; + +const PlanetExample = () => ; +const MugExample = () => ; +const GhostExample = () => ; +const FileExample = () => ; +const IceCreamExample = () => ; +const BrowserExample = () => ; +const BackpackExample = () => ; +const SpeechBubbleExample = () => ; +const CatExample = () => ; + +// $ExpectError +const invalidMoodNumber: KawaiiMood = 5; + +// $ExpectError +const invalidMoodString: KawaiiMood = ''; + +// This is defined on one line to avoid the position of the error moving between TS2/3 +// $ExpectError +const invalidProps: KawaiiProps = { size: '200px' }; diff --git a/types/react-kawaii/tsconfig.json b/types/react-kawaii/tsconfig.json new file mode 100644 index 0000000000..9650d17bb0 --- /dev/null +++ b/types/react-kawaii/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-kawaii-tests.tsx" + ] +} diff --git a/types/react-kawaii/tslint.json b/types/react-kawaii/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-kawaii/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }