changeset 2321:ed0db55f604c

use undefined for 'nothing selected' insetad of null
author drewp@bigasterisk.com
date Thu, 01 Jun 2023 14:20:40 -0700
parents 280be980aaa0
children cdfd2901918a
files light9/fade/Light9FadeUi.ts light9/web/ResourceDisplay.ts tsconfig.json
diffstat 3 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/light9/fade/Light9FadeUi.ts	Thu Jun 01 14:19:42 2023 -0700
+++ b/light9/fade/Light9FadeUi.ts	Thu Jun 01 14:20:40 2023 -0700
@@ -91,9 +91,9 @@
   ctx: NamedNode = new NamedNode(showRoot + "/fade");
   @property() uri!: NamedNode;
   @property() column!: string;
-  @property() effect: NamedNode | null = null;
-  @property() effectAttr: NamedNode | null = null;
-  @state() setting: NamedNode | null = null;
+  @property() effect?: NamedNode;
+  @property() effectAttr?: NamedNode
+  @state() setting?: NamedNode;
 
   @property() value: number = 0.0;
 
@@ -111,18 +111,18 @@
     if (!graph.contains(this.uri, U("rdf:type"), U(":Fader"))) {
       // not loaded yet, perhaps
       this.column = "unset";
-      this.effect = null;
-      this.effectAttr = null;
+      this.effect = undefined;
+      this.effectAttr = undefined;
       return;
     }
     this.column = graph.stringValue(this.uri, U(":column"));
     this.effect = graph.uriValue(this.uri, U(":effect"));
     this.setting = graph.uriValue(this.uri, U(":setting"));
-    if (this.setting !== null) {
+    if (this.setting !== undefined) {
       try {
         this.effectAttr = graph.uriValue(this.setting, U(":effectAttr"));
       } catch (e) {
-        this.effectAttr = null;
+        this.effectAttr = undefined;
       }
     }
   }
@@ -169,7 +169,7 @@
       return;
     }
     const { newValue } = ev.detail;
-    if (this.setting === null) {
+    if (this.setting === undefined) {
       this.setting = this.graph.nextNumberedResource(this.graph.Uri(":fade_set"));
       this.graph.patchObject(this.uri, this.graph.Uri(":setting"), this.setting, this.ctx);
     }
--- a/light9/web/ResourceDisplay.ts	Thu Jun 01 14:19:42 2023 -0700
+++ b/light9/web/ResourceDisplay.ts	Thu Jun 01 14:20:40 2023 -0700
@@ -98,8 +98,11 @@
     if (!this.graph) {
       return; /*too soon, but getTopGraph will call us again*/
     }
+    
     if (this.uri === undefined) {
       this.label = "(unset)";
+    } else if  (this.uri === null) {
+      throw 'use undefined please'
     } else {
       this.graph.runHandler(this.compile.bind(this, this.graph), `label for ${this.uri.id}`);
     }
--- a/tsconfig.json	Thu Jun 01 14:19:42 2023 -0700
+++ b/tsconfig.json	Thu Jun 01 14:20:40 2023 -0700
@@ -27,7 +27,7 @@
     /* Strict Type-Checking Options */
     "strict": true,                                 /* Enable all strict type-checking options. */
     // "noImplicitAny": true,                       /* Raise error on expressions and declarations with an implied 'any' type. */
-    // "strictNullChecks": true,                    /* Enable strict null checks. */
+    "strictNullChecks": true,                    /* Enable strict null checks. */
     // "strictFunctionTypes": true,                 /* Enable strict checking of function types. */
     // "strictBindCallApply": true,                 /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
     // "strictPropertyInitialization": true,        /* Enable strict checking of property initialization in classes. */