diff --git a/framework/core/js/src/common/Store.ts b/framework/core/js/src/common/Store.ts index 02636daeb..970a17679 100644 --- a/framework/core/js/src/common/Store.ts +++ b/framework/core/js/src/common/Store.ts @@ -1,5 +1,6 @@ import app from '../common/app'; import { FlarumRequestOptions } from './Application'; +import fireDebugWarning from './helpers/fireDebugWarning'; import Model, { ModelData, SavedModelData } from './Model'; export interface MetaInformation { @@ -120,11 +121,17 @@ export default class Store { pushObject(data: SavedModelData, allowUnregistered: false): M; pushObject(data: SavedModelData, allowUnregistered = true): M | null { if (!this.models[data.type]) { - if (allowUnregistered) { - return null; + if (!allowUnregistered) { + setTimeout(() => + fireDebugWarning( + `[Flarum 2.0 Deprecation] Cannot push object of type \`${data.type}\`, as that type has not yet been registered in the store. This will throw an error in Flarum 2.0 and later. + +For more information, see https://github.com/flarum/core/pull/3206.` + ) + ); } - throw new Error(`Cannot push object of type ${data.type}, as that type has not yet been registered in the store.`); + return null; } const type = (this.data[data.type] = this.data[data.type] || {});