Skip to content

Incorrect "Cannot find name" when importing default value #26391

Open
@saschanaz

Description

@saschanaz

TypeScript Version: 3.0.1

Search Terms: Cannot find name import default

Code

// fetch.d.ts
declare function fetch(url: string): Promise<any>;
export = fetch;
declare namespace fetch {
  export { fetch as default };
}

// index.ts
import f from "./fetch";
f("url"); // error TS2304: Cannot find name 'f'

Expected behavior: Name should be found

Actual behavior: Cannot find name. Interestingly import { default as f } from "./fetch"; works.

Playground Link: (It doesn't support modules :/)

Related Issues: Couldn't find one

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions