Skip to content

importing merged declorations in js files #61997

Open
@VanillaMaster

Description

@VanillaMaster

🔎 Search Terms

is a type and cannot be imported in JavaScript files;
JSDoc;
Import;
Declaration Merging.

🕗 Version & Regression Information

  • This is the behavior in every version I tried (v5.8.3 - Nightly)

💻 Code

// @filename: foo.impl.js
/**
 * @import { Foo } from "./foo.js"
 */

/**
 * @returns { Foo } 
 */
export function alloc() {
    return {
        prop1: 42,
        prop2: "lorem ipsum"
    }
}

// @filename: foo.js
export * as Foo from "./foo.impl.js"
/**
 * @typedef Foo
 * @prop { number } prop1
 * @prop { string } prop2
 */

// @filename: index.js
import { Foo } from "./foo.js"
//       ^^^ 'Foo' is a type and cannot be imported in JavaScript files. Use 'import("./foo.js").Foo' in a JSDoc type annotation.ts(18042)

const foo = Foo.alloc();

🙁 Actual behavior

tsc/lsp emmits error

🙂 Expected behavior

no error

Additional information about the issue

same example works fine using ts files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions