Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add PURE annotations #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

WIP: Add PURE annotations #21

wants to merge 2 commits into from

Conversation

richardscarrott
Copy link
Owner

@richardscarrott richardscarrott commented Sep 14, 2022

Input:

import { string } from "ok-computer";

console.log(string(1));

$ rollup

Output:

(function () {
  'use strict';

  var INTROSPECT = Symbol.for("ok-computer.introspect");
  var create = (predicate) => (err2) => (value, ...parents) => value === INTROSPECT || !predicate(value, ...parents) ? err2 : void 0;
  var typeOf = (str) => create((value) => typeof value === str)(`Expected typeof ${str}`);
  var string = typeOf("string");

  console.log(string(1));

})();
//# sourceMappingURL=bundle.js.map

@@ -303,7 +303,11 @@ export const max = (num: number) =>
`Expected max ${num}`
);

export const nullish = err(or(undef, nul), 'Expected nullish');
export const nullish = err(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why, but sideEffects: false isn't enough and the following PURE annotations are needed also...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant