Skip to content

Commit

Permalink
Add flow types definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Nov 1, 2017
1 parent 414a08c commit fa71780
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules
/dist/ResizeObserver.js.flow
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"jsnext:main": "dist/ResizeObserver.es.js",
"module": "dist/ResizeObserver.es.js",
"scripts": {
"build": "rollup -c",
"build": "rollup -c && cpy src/index.js.flow dist --rename=ResizeObserver.js.flow",
"test": "npm run test:lint && npm run test:spec",
"test:ci": "npm run test:lint && npm run test:spec:sauce && npm run test:spec:node",
"test:lint": "node ./node_modules/eslint/bin/eslint.js \"**/*.js\" --ignore-pattern \"/dist/\"",
Expand Down Expand Up @@ -48,6 +48,7 @@
"babel-plugin-transform-regenerator": "^6.22.0",
"babel-preset-latest": "^6.24.0",
"babel-preset-stage-2": "^6.22.0",
"cpy-cli": "^1.0.1",
"eslint": "^3.19.0",
"jasmine": "^2.5.3",
"jasmine-core": "^2.5.2",
Expand Down
32 changes: 32 additions & 0 deletions src/index.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// @flow

class DOMRectReadOnly {
+x: number;
+y: number;
+width: number;
+height: number;
+top: number;
+right: number;
+bottom: number;
+left: number;
}

class ResizeObserverEntry {
+target: Element;
+contentRect: DOMRectReadOnly;
}

type Entries = $ReadOnlyArray<ResizeObserverEntry>;

type ResizeObserverCallback = {
(entries: Entries, observer: ResizeObserver): void
};

declare class ResizeObserver {
constructor(ResizeObserverCallback): void;
observe(target: Element): void;
unobserve(target: Element): void;
disconnect(): void;
}

export default typeof ResizeObserver

0 comments on commit fa71780

Please sign in to comment.