Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#33052 from ZhangYiJiang/add-react-…
Browse files Browse the repository at this point in the history
…kawaii

[react-kawaii] Add react-kawaii typings
  • Loading branch information
minestarks authored Feb 14, 2019
2 parents 5167ad6 + 08c29b6 commit 4b9a901
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
33 changes: 33 additions & 0 deletions types/react-kawaii/index.d.ts
Original file line number Diff line number Diff line change
@@ -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>;
22 changes: 22 additions & 0 deletions types/react-kawaii/react-kawaii-tests.tsx
Original file line number Diff line number Diff line change
@@ -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' };
24 changes: 24 additions & 0 deletions types/react-kawaii/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
1 change: 1 addition & 0 deletions types/react-kawaii/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

0 comments on commit 4b9a901

Please sign in to comment.