squirrellyjs / squirrelly

Semi-embedded JS template engine that supports helpers, filters, partials, and template inheritance. 4KB minzipped, written in TypeScript ⛺
https://squirrelly.js.org
MIT License
634 stars 83 forks source link

check if the native prototype method exists. #193

Closed vinothbabu closed 4 years ago

vinothbabu commented 4 years ago

The current usage was breaking the build, so modified the way to check whether the native method exists or not.

nebrelbug commented 4 years ago

@vinothbabu could you provide some details about where the build was failing?

vinothbabu commented 4 years ago

I get this error when I try to build/tests the project locally. This has something to do with the typescript version we have. I thought of giving alternate solution, but seems I had to do a pull-request here every time to check if the build is passing in the pipeline.

Screenshot of the test suite failing:

image

nebrelbug commented 4 years ago

Hmm, seems like a new "feature" was introduced into TypeScript 3.7. Would you mind submitting a pull request changing

if (String.prototype.trimLeft) {}

to

if (!!String.prototype.trimLeft) {}

And etc., as recommended by the TypeScript docs release notes?

vinothbabu commented 4 years ago

Have made the change, it seems it has passed this time.

if (!!String.prototype.trimLeft) {}

The above one works, wondering why the other ways like if (typeof String.prototype.trimRight === "function") {} were breaking with TS 3.7 though they are all valid.