mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
[srcset] Add types
This commit is contained in:
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// Type definitions for srcset 1.0
|
||||
// Project: https://github.com/sindresorhus/srcset#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Parse the HTML `<img>`
|
||||
* [srcset](http://mobile.smashingmagazine.com/2013/08/21/webkit-implements-srcset-and-why-its-a-good-thing/) attribute.
|
||||
*
|
||||
* @param srcset An srcset string.
|
||||
*/
|
||||
export function parse(srcset: string): SrcSetDefinition[];
|
||||
|
||||
/**
|
||||
* Stringify a list of `SrcSetDefinition`s.
|
||||
*
|
||||
* @param srcSetDefinitions An array of `SrcSetDefinition` object.
|
||||
* @returns A srcset string.
|
||||
*/
|
||||
export function stringify(srcSetDefinitions: SrcSetDefinition[]): string;
|
||||
|
||||
export interface SrcSetDefinition {
|
||||
url: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
density?: number;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import srcset = require('srcset');
|
||||
|
||||
const parsed = srcset.parse('banner-HD.jpg 2x, banner-phone.jpg 100w');
|
||||
parsed; // $ExpectType SrcSetDefinition[]
|
||||
|
||||
parsed.push({ url: 'banner-phone-HD.jpg', width: 100, density: 2 });
|
||||
|
||||
srcset.stringify(parsed); // $ExpectType string
|
||||
@@ -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",
|
||||
"srcset-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user