Skip to content

Commit

Permalink
Fix flow
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Mar 18, 2020
1 parent 5e7f3eb commit 86ed830
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/babel-plugin-inject-polyfills/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ import type {
Targets,
MetaDescriptor,
PolyfillProvider,
Utils,
} from "./types";

import createMetaResolver from "./meta-resolver";

export { resolveProvider } from "./config";
export type { PolyfillProvider, MetaDescriptor };
export type { PolyfillProvider, MetaDescriptor, Utils };

export default declare((api, options: Options, dirname: string) => {
api.assertVersion(7);
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-polyfill-provider-es-shims/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import { type PolyfillProvider } from "@babel/plugin-inject-polyfills";
import type { PolyfillProvider, Utils } from "@babel/plugin-inject-polyfills";
import resolve from "resolve";
import debounce from "lodash.debounce";

Expand Down Expand Up @@ -43,7 +43,7 @@ export default ((
}
}

function createDescIterator(cb) {
function createDescIterator(cb: (Descriptor, Utils, Object) => void) {
return (meta, utils, path) => {
const resolved = resolvePolyfill(meta);
if (!resolved) return;
Expand Down
13 changes: 8 additions & 5 deletions packages/babel-polyfill-provider-es-shims/src/mappings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// @flow

// $FlowIgnore
const has = Function.call.bind(Object.hasOwnProperty);

export type Descriptor = {
name: string,
version: string,
Expand All @@ -8,9 +11,9 @@ export type Descriptor = {
global?: false,
};

export const Globals = Object.create(null);
export const StaticProperties = Object.create(null);
export const InstanceProperties = Object.create(null);
export const Globals = {};
export const StaticProperties = {};
export const InstanceProperties = {};

defineGlobal("globalThis", "1.0.0", "globalThis");

Expand Down Expand Up @@ -58,15 +61,15 @@ function defineGlobal(name, version, pkg) {
}

function defineStatic(object, property, version, pkg) {
if (!StaticProperties[object]) StaticProperties[object] = Object.create(null);
if (!has(StaticProperties, object)) StaticProperties[object] = {};

StaticProperties[object][property] = [
createDescriptor(`${object}.${property}`, version, pkg),
];
}

function defineInstance(object, property, version, pkg) {
if (!InstanceProperties[property]) InstanceProperties[property] = [];
if (!has(InstanceProperties, property)) InstanceProperties[property] = [];

InstanceProperties[property].push({
...createDescriptor(`${object}.prototype.${property}`, version, pkg),
Expand Down

0 comments on commit 86ed830

Please sign in to comment.