diff --git a/types/picturefill/index.d.ts b/types/picturefill/index.d.ts new file mode 100644 index 0000000000..f41e46a3d7 --- /dev/null +++ b/types/picturefill/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for picturefill 3.0 +// Project: https://scottjehl.github.io/picturefill/ +// Definitions by: Alexander Azarov +// 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; + +declare module 'picturefill' { + export = picturefill; +} diff --git a/types/picturefill/picturefill-tests.ts b/types/picturefill/picturefill-tests.ts new file mode 100644 index 0000000000..306a3f6ded --- /dev/null +++ b/types/picturefill/picturefill-tests.ts @@ -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 + }); +} diff --git a/types/picturefill/tsconfig.json b/types/picturefill/tsconfig.json new file mode 100644 index 0000000000..0fefbd709d --- /dev/null +++ b/types/picturefill/tsconfig.json @@ -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" + ] +} diff --git a/types/picturefill/tslint.json b/types/picturefill/tslint.json new file mode 100644 index 0000000000..e765bc9e16 --- /dev/null +++ b/types/picturefill/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-single-declare-module": false + } +}