We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d32f86e commit 553bde3Copy full SHA for 553bde3
1 file changed
packages/type/src/is/usage/is-not-undefined.ts
@@ -0,0 +1,25 @@
1
+import { is } from '../lib/is.object';
2
+
3
+// Example usage with the problem
4
+interface Config {
5
+ a?: string;
6
+ b?: string;
7
+}
8
+const config: Config = {
9
+ a: 'x',
10
+ b: 'y'
11
+};
12
13
+function configFunction(value: string): string {
14
+ return '';
15
16
17
+// Cause typescript returns `boolean` this will generate a type error
18
+if (is.not.undefined(config.a)) {
19
+ configFunction(config.a);
20
21
22
+// Cause typescript return `value is undefined` will not generate an error
23
+if (!is.undefined(config.a)) {
24
25
0 commit comments