mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Definitions for ink-spinner
This commit is contained in:
39
types/ink-spinner/index.d.ts
vendored
Normal file
39
types/ink-spinner/index.d.ts
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// Type definitions for ink-spinner 2.0
|
||||
// Project: https://github.com/vadimdemedes/ink-spinner#readme
|
||||
// Definitions by: Łukasz Ostrowski <https://github.com/lukostry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Chalk } from 'chalk';
|
||||
import * as cliSpinners from 'cli-spinners';
|
||||
import { Component } from 'ink';
|
||||
|
||||
type StringifyPartial<T> = {
|
||||
[P in keyof T]?: string;
|
||||
};
|
||||
|
||||
type BooleansPartial<T> = {
|
||||
[P in keyof T]?: boolean;
|
||||
};
|
||||
|
||||
type TupleOfNumbersPartial<T> = {
|
||||
[P in keyof T]?: [number, number, number];
|
||||
};
|
||||
// Omit taken from https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
|
||||
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
type ChalkColorModels = Pick<Chalk, 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'bgRgb' | 'bgHsl' | 'bgHsv' | 'bgHwb'>;
|
||||
type ChalkKeywordsAndHexes = Pick<Chalk, 'keyword' | 'hex' | 'bgKeyword' | 'bgHex'>;
|
||||
type ChalkCommons = Omit<Chalk, keyof ChalkColorModels | keyof ChalkKeywordsAndHexes | 'constructor' | 'level' | 'enabled'>;
|
||||
|
||||
interface SpinnerProps {
|
||||
type?: cliSpinners.SpinnerName;
|
||||
}
|
||||
|
||||
type ChalkProps = BooleansPartial<ChalkCommons>
|
||||
& StringifyPartial<ChalkKeywordsAndHexes>
|
||||
& TupleOfNumbersPartial<ChalkColorModels>;
|
||||
|
||||
declare class Spinner extends Component<SpinnerProps & ChalkProps> { }
|
||||
|
||||
export = Spinner;
|
||||
10
types/ink-spinner/ink-spinner-tests.tsx
Normal file
10
types/ink-spinner/ink-spinner-tests.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
/** @jsx h */
|
||||
import { h } from 'ink';
|
||||
import Spinner from 'ink-spinner';
|
||||
// NOTE: `import Spinner = require('ink-spinner');` will work as well.
|
||||
// If importing using ES6 default import as above,
|
||||
// `allowSyntheticDefaultImports` flag in compiler options needs to be set to `true`
|
||||
|
||||
const Demo = () => {
|
||||
return <Spinner type="line" rgb={[255, 255, 255]} />;
|
||||
};
|
||||
25
types/ink-spinner/tsconfig.json
Normal file
25
types/ink-spinner/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"jsx": "react",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ink-spinner-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/ink-spinner/tslint.json
Normal file
1
types/ink-spinner/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user