Skip to content

NextDrupalBase cannot be used in enableDraftMode() #749

Closed
@JohnAlbin

Description

@JohnAlbin

Package containing the bug

next-drupal (NPM package)

Describe the bug

In the /draft entry point, the enableDraftMode() function accepts a NextDrupal object as its second parameter:

async function enableDraftMode(
  request: NextRequest,
  drupal: NextDrupal
): Promise<Response | never> {

enableDraftMode() then uses that drupal object's validateDraftUrl() method.

That validateDraftUrl() is actually a method of the NextDrupalBase class, so theoretically a developer should be able to pass a NextDrupalBase object to enableDraftMode() and it should work. But the type definition of NextDrupal prevents that; a TypeScript error is thrown during a TS build.

Expected behavior

A developer should be able to pass a NextDrupalBase object to enableDraftMode() and the TypeScript compilation should not fail and, when the code is run, draft mode should be enabled.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions