Skip to content

Poor error guidance for deep imports of packages with @types #24781

Closed
@DanielRosenwasser

Description

@DanielRosenwasser
yarn init --yes
yarn add @types/[email protected]

With noImplicitAny:

import * as acorn from "acorn/dist/acorn_loose";

Error:

Could not find a declaration file for module 'acorn/dist/acorn_loose'. 'c:/Users/Daniel/sample/node_modules/acorn/dist/acorn_loose.js' implicitly has an 'any' type.
  Try `npm install @types/acorn` if it exists or add a new declaration (.d.ts) file containing `declare module 'acorn';`

But @types/acorn already has been installed. The true error is that the declaration files haven't been written for this deeper import. I think we can give a better error message here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    @typesRelates to working with .d.ts files (declaration/definition files) from DefinitelyTypedBugA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions