Sfoglia il codice sorgente

wip strict null checks

Steven Silvester 7 anni fa
parent
commit
440ceac8f2

+ 2 - 4
packages/coreutils/src/activitymonitor.ts

@@ -73,15 +73,13 @@ class ActivityMonitor<Sender, Args> implements IDisposable {
         sender: this._sender,
         args: this._args
       });
-      this._sender = null;
-      this._args = null;
     }, this._timeout);
   }
 
   private _timer = -1;
   private _timeout = -1;
-  private _sender: Sender = null;
-  private _args: Args = null;
+  private _sender: Sender;
+  private _args: Args;
   private _isDisposed = false;
   private _activityStopped = new Signal<this, ActivityMonitor.IArguments<Sender, Args>>(this);
 }

+ 4 - 4
packages/coreutils/src/markdowncodeblocks.ts

@@ -79,22 +79,22 @@ namespace MarkdownCodeBlocks {
         // Check whether this is a single line code block of the form ```a = 10```.
         const firstIndex = line.indexOf(CODE_BLOCK_MARKER);
         const lastIndex = line.lastIndexOf(CODE_BLOCK_MARKER);
-        const isSingleLine = firstIndex != lastIndex
+        const isSingleLine = firstIndex !== lastIndex;
         if (isSingleLine) {
           currentBlock.code = line.substring(firstIndex + CODE_BLOCK_MARKER.length, lastIndex);
           currentBlock.endLine = lineIndex;
           codeBlocks.push(currentBlock);
           currentBlock = null;
         }
-      } else {
+      } else if (currentBlock) {
         if (lineContainsMarker) {
           // End of block, finish it up.
-          currentBlock.endLine = lineIndex-1;
+          currentBlock.endLine = lineIndex - 1;
           codeBlocks.push(currentBlock);
           currentBlock = null;
         } else {
           // Append the current line.
-          currentBlock.code += line + "\n";
+          currentBlock.code += line + '\n';
         }
       }
     }

+ 4 - 7
packages/coreutils/src/modeldb.ts

@@ -117,7 +117,7 @@ interface ICollaborator extends JSONObject {
    * use in places where the full `displayName` would take
    * too much space.
    */
-  readonly shortName?: string;
+  readonly shortName: string;
 }
 
 
@@ -282,7 +282,7 @@ class ObservableValue implements IObservableValue {
    *
    * @param initialValue: the starting value for the `ObservableValue`.
    */
-  constructor(initialValue?: JSONValue) {
+  constructor(initialValue: JSONValue = {}) {
     this._value = initialValue;
   }
 
@@ -571,11 +571,8 @@ class ModelDB implements IModelDB {
     if (this.isDisposed) {
       return;
     }
-    let db = this._db;
-    this._db = null;
-
     if (this._toDispose) {
-      db.dispose();
+      this._db.dispose();
     }
     this._disposables.dispose();
   }
@@ -591,7 +588,7 @@ class ModelDB implements IModelDB {
   }
 
   private _basePath: string;
-  private _db: ModelDB | ObservableMap<IObservable> = null;
+  private _db: ModelDB | ObservableMap<IObservable>;
   private _toDispose = false;
   private _disposables = new DisposableSet();
 }

+ 1 - 0
packages/coreutils/tsconfig.json

@@ -4,6 +4,7 @@
     "noImplicitAny": true,
     "noEmitOnError": true,
     "noUnusedLocals": true,
+    "strictNullChecks": true,
     "module": "commonjs",
     "moduleResolution": "node",
     "target": "ES5",