Skip to content

Type error '"@hapi/hapi"' has no exported member named 'Util'. Did you mean 'Utils'?  #4510

Open
@eriktoyra

Description

@eriktoyra

Runtime

Node.js

Runtime version

v20.10.0

Module version

21.3.10

Last module version without issue

21.0.0

Used with

@apollo/server, @as-integrations/hapi

Any other relevant information

@hapi/hapi 21.0.0 with @types/hapi_hapi 20.0.13 installed works. But since @types/hapi_hapi should not be used with @hapi/hapi 21.0+ this is not an option.

What are you trying to achieve or the steps to reproduce?

When updating Apollo Server from v3 to v4 I stumbled on a breaking change in the type definitions provided in a change targeting [email protected].

It seems the namespace Util, previously provided by DefinatelyTyped in@types/hapi_hapi, has been renamed from Util to Utils by mistake. #4398 moved the type definitions as-is from @types/hapi_hapi into Hapi. But in the subsequent #4399 when the type definitions where split out to multiple files, the namespace was renamed from Util to Utils.

Compare this line of code with the the resulting change in #4399. This seems like a typo mistake. But it infers a breaking change in other packages referencing Util.

What was the result you got?

@as-integrations references the Util type from @hapi/hapi, as this is the expected name up until the change in #4399. This leads to a breaking change towards @as-integrations and other packages importing Util from @hapi/hapi.

import type {
  Lifecycle,
  ReqRef,
  Request,
  ResponseToolkit,
  RouteOptions,
  Server,
  Util,
} from '@hapi/hapi';

This leads to the type error:

'"@hapi/hapi"' has no exported member named 'Util'. Did you mean 'Utils'? ts(2724)

What result did you expect?

@hapi/hapi should provide Util as namespace and not Utils for backward compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    typesTypeScript type definitions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions