Merge pull request #19579 from alaz/picturefill

Type definitions for `picturefill`
This commit is contained in:
Nathan Shively-Sanders
2017-09-07 13:20:46 -07:00
committed by GitHub
4 changed files with 61 additions and 0 deletions

18
types/picturefill/index.d.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
// Type definitions for picturefill 3.0
// Project: https://scottjehl.github.io/picturefill/
// Definitions by: Alexander Azarov <https://github.com/alaz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Picturefill {
type ElementNullable = Element | null;
interface EvaluateArg {
reevaluate?: boolean;
elements: NodeList | ElementNullable[];
}
}
declare function picturefill(arg?: Picturefill.EvaluateArg): void;
export = picturefill;
export as namespace picturefill;

View File

@@ -0,0 +1,17 @@
function test_elements() {
// no args
picturefill();
// Element[]
picturefill({elements: [ document.getElementById('#id') ]});
// NodeList
picturefill({elements: document.querySelectorAll('img')});
}
function test_optional() {
picturefill({
elements: [],
reevaluate: true
});
}

View File

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

View File

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