diff --git a/index.js b/index.js index ddfc2f3..10f63d8 100644 --- a/index.js +++ b/index.js @@ -31,16 +31,18 @@ module.exports = exported || function isSet(x) { return false; } try { - $setHas.call(x); - if ($mapHas) { - try { - $mapHas.call(x); - } catch (e) { - return true; + if ($setHas) { + $setHas.call(x, 0); + if ($mapHas) { + try { + $mapHas.call(x, 0); + } catch (e) { + return true; + } } + // @ts-expect-error TS can't figure out that $Set is always truthy here + return x instanceof $Set; // core-js workaround, pre-v2.5.0 } - // @ts-expect-error TS can't figure out that $Set is always truthy here - return x instanceof $Set; // core-js workaround, pre-v2.5.0 } catch (e) {} return false; }; diff --git a/package.json b/package.json index f2572a5..862705c 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,8 @@ }, "publishConfig": { "ignore": [ - ".github/workflows" + ".github/workflows", + "types" ] }, "testling": { diff --git a/tsconfig.json b/tsconfig.json index ac228e2..9afd37b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,8 @@ { "extends": "@ljharb/tsconfig", + "compilerOptions": { + "maxNodeModuleJsDepth": 0, + }, "exclude": [ "coverage", ], diff --git a/types/es-set/implementation.d.ts b/types/es-set/implementation.d.ts new file mode 100644 index 0000000..656643e --- /dev/null +++ b/types/es-set/implementation.d.ts @@ -0,0 +1,3 @@ +declare module 'es-set/implementation' { + export = SetConstructor; +} diff --git a/types/es-set/index.d.ts b/types/es-set/index.d.ts new file mode 100644 index 0000000..826cd34 --- /dev/null +++ b/types/es-set/index.d.ts @@ -0,0 +1,5 @@ +declare module 'es-set' { + const Set: SetConstructor; + + export = Set; +} diff --git a/types/es-set/polyfill.d.ts b/types/es-set/polyfill.d.ts new file mode 100644 index 0000000..d599f80 --- /dev/null +++ b/types/es-set/polyfill.d.ts @@ -0,0 +1,5 @@ +declare module 'es-set/polyfill' { + function getPolyfill(): SetConstructor; + + export = getPolyfill; +} diff --git a/types/es-set/shim.d.ts b/types/es-set/shim.d.ts new file mode 100644 index 0000000..da76dbf --- /dev/null +++ b/types/es-set/shim.d.ts @@ -0,0 +1,5 @@ +declare module 'es-set/shim' { + function shim(): SetConstructor; + + export = shim; +}