How to get a reference to a CodeCell?

I am able to iterate through the cells in a Notebook using the method below, however each cell implements ICellModel. In order to get the cell output I have cast the model to ICodeCellModel. However, what is the correct way to access the outputs of these Cells?

const extension: JupyterFrontEndPlugin<object> = {
  id: "etc-jupyterlab-telemetry:plugin",
  autoStart: true,
  requires: [INotebookTracker],
  activate: (app: JupyterFrontEnd, tracker: INotebookTracker) => {

tracker.widgetAdded.connect((tracker: INotebookTracker, nbPanel: NotebookPanel) => {

      (cell: Cell<ICellModel>,
        index: number,
        array: readonly Cell<ICellModel>[]
      ) => {
        console.log((cell.model as ICodeCellModel).toJSON());
return {};

See isCodeCellModel: jupyterlab/model.ts at b4db7f03d2ad0b91a9c8c252c56ae5e4a9408fbb · jupyterlab/jupyterlab · GitHub

@jasongrout Thank you. I didn’t even know TypeScript had an is operator until today :slight_smile:

I see how that works. Thanks again.