diff --git a/packages/jspsych/src/JsPsych.ts b/packages/jspsych/src/JsPsych.ts index ce6c0855..1aecde0f 100644 --- a/packages/jspsych/src/JsPsych.ts +++ b/packages/jspsych/src/JsPsych.ts @@ -504,13 +504,17 @@ export class JsPsych { this.current_trial = trial; this.current_trial_finished = false; - // instantiate the plugin for this trial - const info = trial.type.info; - trial.type = new trial.type(this); - // process all timeline variables for this trial this.evaluateTimelineVariables(trial); + // instantiate the plugin for this trial + trial.type = { + // this is a hack to internally keep the old plugin object structure and prevent touching more + // of the core jspsych code + ...autoBind(new trial.type(this)), + info: trial.type.info, + }; + // evaluate variables that are functions this.evaluateFunctionParameters(trial); diff --git a/packages/jspsych/src/modules/plugins.ts b/packages/jspsych/src/modules/plugins.ts index c97792a5..434a108e 100644 --- a/packages/jspsych/src/modules/plugins.ts +++ b/packages/jspsych/src/modules/plugins.ts @@ -140,13 +140,10 @@ export interface PluginInfo { } export interface JsPsychPlugin { - info: I; trial(display_element: HTMLElement, trial: TrialType): void; } export type TrialType = InferredParameters & UniversalPluginParameters; -export type PluginParameters
> = InferredParameters<
- P["info"]["parameters"]
->;
+export type PluginParameters = InferredParameters;
diff --git a/packages/jspsych/tests/core/functions-as-parameters.test.ts b/packages/jspsych/tests/core/functions-as-parameters.test.ts
index eb5026ef..de5f6382 100644
--- a/packages/jspsych/tests/core/functions-as-parameters.test.ts
+++ b/packages/jspsych/tests/core/functions-as-parameters.test.ts
@@ -166,7 +166,7 @@ describe("nested parameters as functions", () => {
};
class FunctionTestPlugin implements JsPsychPlugin