Jelajahi Sumber

Merge pull request #1061 from vidartf/nbformat-typing

Tighten typing restriction of nbformat.ICell
Steven Silvester 8 tahun lalu
induk
melakukan
ce14f09991

+ 3 - 3
src/notebook/cells/model.ts

@@ -353,12 +353,12 @@ class CodeCellModel extends CellModel implements ICodeCellModel {
   /**
    * Construct a new code cell with optional original cell content.
    */
-  constructor(cell?: nbformat.IBaseCell) {
+  constructor(cell?: nbformat.ICell) {
     super(cell);
     this._outputs = new OutputAreaModel();
     if (cell && cell.cell_type === 'code') {
-      this.executionCount = (cell as nbformat.ICodeCell).execution_count;
-      for (let output of (cell as nbformat.ICodeCell).outputs) {
+      this.executionCount = cell.execution_count;
+      for (let output of cell.outputs) {
         this._outputs.add(output);
       }
     }

+ 1 - 1
src/notebook/cells/widget.ts

@@ -432,7 +432,7 @@ class CodeCellWidget extends BaseCellWidget {
    * Execute the cell given a kernel.
    */
   execute(kernel: IKernel): Promise<KernelMessage.IExecuteReplyMsg> {
-    let model = this.model as ICodeCellModel;
+    let model = this.model;
     let code = model.source;
     if (!code.trim()) {
       model.executionCount = null;

+ 1 - 1
src/notebook/notebook/model.ts

@@ -502,7 +502,7 @@ namespace NotebookModel {
      * @returns A new code cell. If a source cell is provided, the
      *   new cell will be intialized with the data from the source.
      */
-    createCodeCell(source?: nbformat.IBaseCell): ICodeCellModel {
+    createCodeCell(source?: nbformat.ICell): ICodeCellModel {
       return new CodeCellModel(source);
     }
 

+ 1 - 1
src/notebook/notebook/nbformat.ts

@@ -288,7 +288,7 @@ namespace nbformat {
    * A cell union type.
    */
   export
-  type ICell = IBaseCell | IRawCell | IMarkdownCell | ICodeCell;
+  type ICell = IRawCell | IMarkdownCell | ICodeCell;
 
 
   /**