mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Added type definition for string-pixel-width (#35046)
This commit is contained in:
parent
a9cb5fa8b8
commit
0558f65597
18
types/string-pixel-width/index.d.ts
vendored
Normal file
18
types/string-pixel-width/index.d.ts
vendored
Normal 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;
|
||||
}
|
||||
14
types/string-pixel-width/string-pixel-width-tests.ts
Normal file
14
types/string-pixel-width/string-pixel-width-tests.ts
Normal 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 });
|
||||
23
types/string-pixel-width/tsconfig.json
Normal file
23
types/string-pixel-width/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/string-pixel-width/tslint.json
Normal file
1
types/string-pixel-width/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user