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

goog.isDateLike is triggered by others' sketchy practices #27

Open
tekacs opened this issue Apr 7, 2021 · 0 comments
Open

goog.isDateLike is triggered by others' sketchy practices #27

tekacs opened this issue Apr 7, 2021 · 0 comments

Comments

@tekacs
Copy link

tekacs commented Apr 7, 2021

I've had to stop using cljs-oops for a subset of my uses, specifically https://capacitorjs.com plugins[1], because their top-level plugin modules return a Proxy that behaves somewhat like this (not exactly, but this achieves a similar effect):

const p = new Proxy({}, {get: () => () => true})

That is to say, typeof p.anythingAtAll is 'function'.

Unfortunately, goog.isDateLike only looks for goog.isObject and typeof val.getFullYear == 'function'.

I fully appreciate that this style of duck-typed checking is common in JS, including for promises (as thenables) and similar -- and also that this is more of an upstream quirk than anything else.

That said, given that upstream libraries can't always be changed, I wanted to propose configuration to pick which of the safety checks are run, one at a time (maybe a set like #{:date-like :string-like ...}?)

I find that I rarely trigger the date-like check in ordinary use and disabling it for my own codebase would be helpful for this situation -- on the other hand, I find the other runtime checks valuable and do run into them, so I would love to leave them enabled.

I almost wrote the PR alongside the issue, but I wanted to get your thoughts before doing so, in case you have a preference for how such a thing would work.

Thanks so much for the library -- I like it enough to have wrapped it at https://github.com/tekacs/access in a different syntax, which is primarily how I use it. :)

[1]: such as @capacitor/filesystem, which returns the output of registerPlugin in @capacitor/core

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

No branches or pull requests

1 participant