Add react-kawaii typings

This commit is contained in:
Zhang Yi Jiang 2019-02-14 11:50:09 +08:00
parent 93ed5c2843
commit 08c29b69ff
4 changed files with 80 additions and 0 deletions

33
types/react-kawaii/index.d.ts vendored Normal file
View File

@ -0,0 +1,33 @@
// Type definitions for react-kawaii 0.11
// Project: https://github.com/miukimiu/react-kawaii
// Definitions by: Zhang Yi Jiang <https://github.com/ZhangYiJiang>
// 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<KawaiiProps>;
export const Mug: React.ComponentType<KawaiiProps>;
export const Browser: React.ComponentType<KawaiiProps>;
export const Ghost: React.ComponentType<KawaiiProps>;
export const Cat: React.ComponentType<KawaiiProps>;
export const IceCream: React.ComponentType<KawaiiProps>;
export const CreditCard: React.ComponentType<KawaiiProps>;
export const File: React.ComponentType<KawaiiProps>;
export const Backpack: React.ComponentType<KawaiiProps>;
export const Planet: React.ComponentType<KawaiiProps>;

View File

@ -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 = () => <Planet size={200} mood="blissful" color="#FDA7DC" />;
const MugExample = () => <Mug size={200} mood="ko" color="rebeccapurple" />;
const GhostExample = () => <Ghost size={200} mood="lovestruck" color="#E0E4E8" />;
const FileExample = () => <File size={200} mood="blissful" color="#83D1FB" />;
const IceCreamExample = () => <IceCream mood="happy" />;
const BrowserExample = () => <Browser size={500} />;
const BackpackExample = () => <Backpack />;
const SpeechBubbleExample = () => <SpeechBubble />;
const CatExample = () => <Cat />;
// $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' };

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }