mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Add types for coinlist
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import coins = require('coinlist');
|
||||
import coinsJson = require('coinlist/src/coins.json');
|
||||
|
||||
// $ExpectType Coin[] & CoinsAPI
|
||||
coins;
|
||||
|
||||
// $ExpectType Coin[]
|
||||
coinsJson;
|
||||
|
||||
let coinsArr = [
|
||||
{
|
||||
id: 'bitcoin',
|
||||
symbol: 'BTC',
|
||||
name: 'Bitcoin',
|
||||
},
|
||||
{
|
||||
id: 'litecoin',
|
||||
symbol: 'LTC',
|
||||
name: 'Litecoin',
|
||||
},
|
||||
];
|
||||
|
||||
coinsArr = coins;
|
||||
coinsArr = coinsJson;
|
||||
|
||||
// $ExpectType Coin | undefined
|
||||
coins.get('BTC');
|
||||
|
||||
// $ExpectType string | undefined
|
||||
coins.get('BTC', 'name');
|
||||
// $ExpectType string | undefined
|
||||
coins.get('BTC', 'symbol');
|
||||
// $ExpectType string | undefined
|
||||
coins.get('BTC', 'id');
|
||||
|
||||
coins.map(coin => coin.name);
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for coinlist 3.1
|
||||
// Project: https://github.com/lukechilds/coinlist
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import coinsJson = require('./src/coins.json');
|
||||
|
||||
export = coins;
|
||||
|
||||
declare const coins: coins.Coin[] & coins.CoinsAPI;
|
||||
|
||||
declare namespace coins {
|
||||
type Coin = coinsJson.Coin;
|
||||
|
||||
interface CoinsAPI {
|
||||
get(symbol: string): Coin | undefined;
|
||||
get(symbol: string, property: 'id' | 'symbol' | 'name'): string | undefined;
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
export = coins;
|
||||
|
||||
declare const coins: coins.Coin[];
|
||||
|
||||
declare namespace coins {
|
||||
interface Coin {
|
||||
id: string;
|
||||
symbol: string;
|
||||
name: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"src/coins.json.d.ts",
|
||||
"coinlist-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user