feat(hex2dec): adds types for hex2dec (#46018)

This commit is contained in:
Adriaan Knapen 2020-07-12 10:07:12 +02:00 committed by GitHub
parent e8378bbd71
commit b5503ad6dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import hex2dec = require('hex2dec');
hex2dec.hexToDec('0xFA'); // $ExpectType string
hex2dec.decToHex('250'); // $ExpectType string
hex2dec.decToHex('250', { prefix: false }); // $ExpectType string

13
types/hex2dec/index.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
// Type definitions for hex2dec 1.1
// Project: https://github.com/donmccurdy/hex2dec#readme
// Definitions by: Adriaan Knapen <https://github.com/Addono>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Takes a hexadecimal string and returns it as a decimal string.
*/
export function hexToDec(hexStr: string): string;
/**
* Takes a decimal string and returns it as a hexadecimal string.
*/
export function decToHex(decStr: string, opts?: { prefix?: boolean }): string;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"hex2dec-tests.ts"
]
}

View File

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