Closed harrison-symes closed 5 years ago
I'm not a big fan of that approach. Here is why: https://www.codereadability.com/how-to-check-for-undefined-in-javascript/
I'll think about introducing a setting that would toggle one or the other version. I really doubt anyone would use both versions in the same project.
In the meantime you can play around with custom templates to get this done:
"postfix.customTemplates": [
{
"name": "undef",
"body": "if (typeof {{expr}} === 'undefined') {\n${0}\n}",
"description": "if (typeof expr === 'undefined')",
"when": [
"identifier",
"expression"
]
}
]
Release should be ready quite soon.
Current postfixing
.undefined
to the end of an entry fixes it to:It is safer to check
if (tpyeof value === "undefined") {
instead.The same goes for
notundefined
Alternatively, create a new postfix for this specific typeof scenario