Type definitions for picturefill

It's a module function, so should be imported like

```
import picturefill = require('picturefill');
```
This commit is contained in:
Alexander Azarov
2017-09-06 10:29:35 +03:00
parent 67d401c875
commit 76105d9466
4 changed files with 65 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
// 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;
declare module 'picturefill' {
export = picturefill;
}
+17
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
});
}
+23
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"
]
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-single-declare-module": false
}
}