question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

not operator (anything but)

See original GitHub issue

tl;dr:

(param: Any) => not String
// shorthand
(param: Any) => !String

// union case
(param: Any) => not(String | Array)
// short hand
(param: Any) => !(String | Array)

Sometimes it’s way easier and convenient to define the type by discarding one or several. There’s also the possibility to define it as a substraction—e.g. Any - String—but that would not be very conventional.

TypeScript approaches

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
ericelliottcommented, May 16, 2018

I like it.

0reactions
Mouvediacommented, May 16, 2018

newly introduced types may be considered acceptable by the type system, even if they’re not acceptable types in practice

That’s to be expected. Let’s say you had !Array before typed arrays were introduced and it doesn’t cover Int16Array, I wouldn’t blame rtype. The type will have to be updated to !Array & !TypedArray; it’s such a rare occurence that I don’t mind.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logical NOT (!) - JavaScript - MDN Web Docs - Mozilla
The logical NOT (!) (logical complement, negation) operator takes truth to falsity and vice versa. It is typically used with boolean (logical) values....
Read more >
*AND, *OR, and *NOT operators in CL logical expressions - IBM
The logical operators *AND and *OR specify the relationship between operands in a logical expression. The logical operator *NOT is used to negate...
Read more >
Using the Not Operator in If Conditions in Java - Baeldung
The not operator is a logical operator, represented in Java by the ! symbol. It's a unary operator that takes a boolean value...
Read more >
What is the !! (not not) operator in JavaScript? - Stack Overflow
It converts Object to boolean . If it was falsey (e.g., 0 , null , undefined , etc.), it would be false ,...
Read more >
Using the "not" Boolean Operator in Python
Python's not operator allows you to invert the truth value of Boolean expressions and objects. You can use this operator in Boolean contexts, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found