diff --git a/packages/application/src/mimerenderers.ts b/packages/application/src/mimerenderers.ts index e2f370c1c134..a30f15dd1f87 100644 --- a/packages/application/src/mimerenderers.ts +++ b/packages/application/src/mimerenderers.ts @@ -137,7 +137,7 @@ export function createRendermimePlugin( rendermime, modelName: option.modelName, name: option.name, - primaryFileType: registry.getFileType(option.primaryFileType)!, // TODO: Can we assume this is not undefined? + primaryFileType: registry.getFileType(option.primaryFileType), fileTypes: option.fileTypes, defaultFor: option.defaultFor, defaultRendered: option.defaultRendered, diff --git a/packages/application/src/router.ts b/packages/application/src/router.ts index aa5e4867388b..72aada0998d3 100644 --- a/packages/application/src/router.ts +++ b/packages/application/src/router.ts @@ -7,7 +7,12 @@ import { URLExt } from '@jupyterlab/coreutils'; import { CommandRegistry } from '@lumino/commands'; -import { PromiseDelegate, Token, ReadonlyJSONObject } from '@lumino/coreutils'; +import { + PromiseDelegate, + Token, + ReadonlyPartialJSONObject, + PartialJSONObject +} from '@lumino/coreutils'; import { DisposableDelegate, IDisposable } from '@lumino/disposable'; @@ -159,10 +164,7 @@ export class Router implements IRouter { try { const request = this.current.request; - const result = await commands.execute( - command, - (current as unknown) as ReadonlyJSONObject // TODO: Should typings in Lumino be updated to be partial? - ); + const result = await commands.execute(command, current); if (result === stop) { queue.length = 0; console.log(`Routing ${request} was short-circuited by ${command}`); diff --git a/packages/application/src/tokens.ts b/packages/application/src/tokens.ts index 2cf9088a0bc5..c1756adcdfc3 100644 --- a/packages/application/src/tokens.ts +++ b/packages/application/src/tokens.ts @@ -5,7 +5,7 @@ import { CommandRegistry } from '@lumino/commands'; import { ServerConnection, ServiceManager } from '@jupyterlab/services'; -import { Token } from '@lumino/coreutils'; +import { Token, ReadonlyPartialJSONObject } from '@lumino/coreutils'; import { IDisposable } from '@lumino/disposable'; @@ -109,7 +109,7 @@ export namespace IRouter { /** * The parsed location currently being routed. */ - export interface ILocation { + export interface ILocation extends ReadonlyPartialJSONObject { /** * The location hash. */ diff --git a/packages/docregistry/src/mimedocument.ts b/packages/docregistry/src/mimedocument.ts index 5849ef9dc458..9341ee0cad0e 100644 --- a/packages/docregistry/src/mimedocument.ts +++ b/packages/docregistry/src/mimedocument.ts @@ -272,7 +272,7 @@ export class MimeDocumentFactory extends ABCWidgetFactory { */ protected createNewWidget(context: DocumentRegistry.Context): MimeDocument { const ft = this._fileType; - const mimeType = ft.mimeTypes.length ? ft.mimeTypes[0] : 'text/plain'; + const mimeType = ft?.mimeTypes.length ? ft.mimeTypes[0] : 'text/plain'; const rendermime = this._rendermime.clone({ resolver: context.urlResolver @@ -287,8 +287,8 @@ export class MimeDocumentFactory extends ABCWidgetFactory { dataType: this._dataType }); - content.title.iconClass = ft.iconClass ?? ''; - content.title.iconLabel = ft.iconLabel ?? ''; + content.title.iconClass = ft?.iconClass ?? ''; + content.title.iconLabel = ft?.iconLabel ?? ''; const widget = new MimeDocument({ content, context }); @@ -298,7 +298,7 @@ export class MimeDocumentFactory extends ABCWidgetFactory { private _rendermime: IRenderMimeRegistry; private _renderTimeout: number; private _dataType: 'string' | 'json'; - private _fileType: DocumentRegistry.IFileType; + private _fileType: DocumentRegistry.IFileType | undefined; } /** @@ -313,7 +313,7 @@ export namespace MimeDocumentFactory { /** * The primary file type associated with the document. */ - primaryFileType: DocumentRegistry.IFileType; + primaryFileType: DocumentRegistry.IFileType | undefined; /** * The rendermime instance. diff --git a/packages/observables/src/observablejson.ts b/packages/observables/src/observablejson.ts index 2bb7ebaa963e..80f0eac6e605 100644 --- a/packages/observables/src/observablejson.ts +++ b/packages/observables/src/observablejson.ts @@ -5,7 +5,7 @@ import { JSONExt, JSONObject, PartialJSONObject, - PartialJSONValue + ReadonlyPartialJSONValue } from '@lumino/coreutils'; import { Message } from '@lumino/messaging'; @@ -16,7 +16,7 @@ import { IObservableMap, ObservableMap } from './observablemap'; * An observable JSON value. */ export interface IObservableJSON - extends IObservableMap { + extends IObservableMap { /** * Serialize the model to JSON. */ @@ -30,13 +30,15 @@ export namespace IObservableJSON { /** * A type alias for observable JSON changed args. */ - export type IChangedArgs = IObservableMap.IChangedArgs; + export type IChangedArgs = IObservableMap.IChangedArgs< + ReadonlyPartialJSONValue + >; } /** * A concrete Observable map for JSON data. */ -export class ObservableJSON extends ObservableMap { +export class ObservableJSON extends ObservableMap { /** * Construct a new observable JSON object. */ @@ -58,7 +60,7 @@ export class ObservableJSON extends ObservableMap { const value = this.get(key); if (value !== undefined) { - out[key] = JSONExt.deepCopy(value); + out[key] = JSONExt.deepCopy(value) as PartialJSONObject; } } return out; diff --git a/packages/rendermime/src/attachmentmodel.ts b/packages/rendermime/src/attachmentmodel.ts index 8eceacf48767..0255172ab579 100644 --- a/packages/rendermime/src/attachmentmodel.ts +++ b/packages/rendermime/src/attachmentmodel.ts @@ -160,8 +160,7 @@ export class AttachmentModel implements IAttachmentModel { let oldValue = observable.get(key); let newValue = data[key]; if (oldValue !== newValue) { - // TODO: Should we do a deepcopy? Or make observalbe type as readonly? - observable.set(key, newValue as PartialJSONValue | undefined); + observable.set(key, newValue); } } }