Skip to content

Commit

Permalink
Fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vidartf committed Dec 20, 2019
1 parent 3565c21 commit a1b113d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
12 changes: 7 additions & 5 deletions examples/cell/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ function main(): void {

// Handle the mimeType for the current kernel.
session.kernelChanged.connect(() => {
void session.kernel.ready.then(() => {
const lang = session.kernel.info.language_info;
const mimeType = mimeService.getMimeTypeByLanguage(lang);
cellWidget.model.mimeType = mimeType;
});
if (session.kernel) {
void session.kernel.ready.then(() => {
const lang = session.kernel!.info!.language_info;
const mimeType = mimeService.getMimeTypeByLanguage(lang);
cellWidget.model.mimeType = mimeType;
});
}
});

// Use the default kernel.
Expand Down
2 changes: 1 addition & 1 deletion examples/filebrowser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function createApp(manager: ServiceManager.IManager): void {
commands.addCommand('file-save', {
execute: () => {
let context = docManager.contextForWidget(activeWidget);
return context.save();
return context?.save();
}
});
commands.addCommand('file-cut', {
Expand Down
6 changes: 3 additions & 3 deletions examples/notebook/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ export const SetupCommands = (
commands.addCommand(cmdIds.invokeNotebook, {
label: 'Invoke Notebook',
execute: () => {
if (nbWidget.content.activeCell.model.type === 'code') {
if (nbWidget.content.activeCell?.model.type === 'code') {
return commands.execute(cmdIds.invoke);
}
}
});
commands.addCommand(cmdIds.selectNotebook, {
label: 'Select Notebook',
execute: () => {
if (nbWidget.content.activeCell.model.type === 'code') {
if (nbWidget.content.activeCell?.model.type === 'code') {
return commands.execute(cmdIds.select);
}
}
Expand All @@ -77,7 +77,7 @@ export const SetupCommands = (
execute: () => nbWidget.context.save()
});

let searchInstance: SearchInstance;
let searchInstance: SearchInstance | undefined;
commands.addCommand(cmdIds.startSearch, {
label: 'Find...',
execute: () => {
Expand Down

0 comments on commit a1b113d

Please sign in to comment.