浏览代码

Merge pull request #2688 from ian-r-rose/more_coreutils_strictNullCheck

More updates to IModelDB and IObservableValue for strictNullCheck.
Steven Silvester 7 年之前
父节点
当前提交
620385c61c
共有 1 个文件被更改,包括 11 次插入11 次删除
  1. 11 11
      packages/coreutils/src/modeldb.ts

+ 11 - 11
packages/coreutils/src/modeldb.ts

@@ -71,9 +71,9 @@ interface IObservableValue extends IObservable {
   readonly changed: ISignal<IObservableValue, ObservableValue.IChangedArgs>;
 
   /**
-   * Get the current value.
+   * Get the current value, or `undefined` if it has not been set.
    */
-  get(): JSONValue;
+  get(): JSONValue | undefined;
 
   /**
    * Set the value.
@@ -238,12 +238,12 @@ interface IModelDB extends IDisposable {
   createValue(path: string): IObservableValue;
 
   /**
-   * Get a value at a path. That value must already have
-   * been created using `createValue`.
+   * Get a value at a path, or `undefined if it has not been set
+   * That value must already have been created using `createValue`.
    *
    * @param path: the path for the value.
    */
-  getValue(path: string): JSONValue;
+  getValue(path: string): JSONValue | undefined;
 
   /**
    * Set a value at a path. That value must already have
@@ -308,7 +308,7 @@ class ObservableValue implements IObservableValue {
   }
 
   /**
-   * Get the current value.
+   * Get the current value, or `undefined` if it has not been set.
    */
   get(): JSONValue {
     return this._value;
@@ -357,12 +357,12 @@ namespace ObservableValue {
     /**
      * The old value.
      */
-    oldValue: JSONValue;
+    oldValue: JSONValue | undefined;
 
     /**
      * The new value.
      */
-    newValue: JSONValue;
+    newValue: JSONValue | undefined;
   }
 }
 
@@ -507,12 +507,12 @@ class ModelDB implements IModelDB {
   }
 
   /**
-   * Get a value at a path. That value must already have
-   * been created using `createValue`.
+   * Get a value at a path, or `undefined if it has not been set
+   * That value must already have been created using `createValue`.
    *
    * @param path: the path for the value.
    */
-  getValue(path: string): JSONValue {
+  getValue(path: string): JSONValue | undefined {
     let val = this.get(path);
     if (!val || val.type !== 'Value') {
       throw Error('Can only call getValue for an ObservableValue');