Added type definition for string-pixel-width (#35046)

This commit is contained in:
Graham Dyson 2019-04-29 07:59:44 +01:00 committed by Wesley Wigham
parent a9cb5fa8b8
commit 0558f65597
4 changed files with 56 additions and 0 deletions

18
types/string-pixel-width/index.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
// Type definitions for string-pixel-width 1.7
// Project: https://github.com/adambisek/string-pixel-width#readme
// Definitions by: Graham Dyson <https://github.com/grahamdyson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = getWidth;
declare function getWidth(
string: string,
settings?: Settings,
): number;
interface Settings {
bold?: boolean;
font?: "andale mono"|"arial"|"avenir next"|"avenir"|"comic sans ms"|"courier new"|"georgia"|"impact"|"open sans"|"tahoma"|"times new roman"|"trebuchet ms"|"verdana"|"webdings";
italic?: boolean;
size?: number;
}

View File

@ -0,0 +1,14 @@
import stringPixelWidth = require('string-pixel-width');
// $ExpectType number
stringPixelWidth("test");
// $ExpectType number
stringPixelWidth("test", {});
// $ExpectType number
stringPixelWidth("test", { bold: true });
// $ExpectType number
stringPixelWidth("test", { font: "arial" });
// $ExpectType number
stringPixelWidth("test", { italic: true });
// $ExpectType number
stringPixelWidth("test", { size: 10 });

View File

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

View File

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