Skip to content

@import * as namespace cannot be used with @implementsΒ #60563

Closed
@Peeja

Description

@Peeja

πŸ”Ž Search Terms

  • cannot be used as a value because it was imported using 'import type'
  • implements

πŸ•— Version & Regression Information

  • I was unable to test this on prior versions (to v4.1.5) because every-ts failed to build them.

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?checkJs=true&allowJs=true&moduleResolution=3&target=9&module=100&ts=5.6.3#code/PTAEAEEMBtoewO4CkDOAoEEDGALAplgNapoZjgBmAltHgHaQC2eAXKA8ygA6RZ4B0AF3R4AHlzgAnQaCp1BeSRV55QAMThxIAI1qgA3mlCgKmgBQBKNgDc4VACYBuNAF9SZCNVodWoYQFoqRglpIXQgkJlBAE8uVQAqUEgUUAA5AGUTSThGUAAifmAfbhU85zQxSNAsaGSUgBUcOQBzRshBAGFIOg04WWDaZnkUjP5enT19N1JMShp6Jl8AKxRA4KlBfhWMePijRPAIjdBE5LTMimzcgHJC4p4+a-3gGd2ICMH6YQNR8d08FwnF6VY41OqgRotNqdbq9AxuIA

πŸ’» Code

// @allowJs
// @checkJs

// @filename: namespace.ts
export interface Fooable {
  foo(): void;
}


// @filename: ts-import.ts
import type * as NS from "./namespace";

export class ThingThatCanFoo implements NS.Fooable {}


// @filename: js-import.js
/**
 * @import * as NS from './namespace'
 */

/** @implements {NS.Fooable} */
export class ThingThatCanFoo {}

πŸ™ Actual behavior

  • /** @implements {NS.Fooable} */ has error: 'NS' cannot be used as a value because it was imported using 'import type'.
  • Both versions of ThingThatCanFoo correctly report that they do not fully implement Fooable.

πŸ™‚ Expected behavior

  • /** @implements {NS.Fooable} */ should not have an error, exactly like implements NS.Fooable above.
  • Both versions of ThingThatCanFoo should still report that they do not fully implement Fooable.

Additional information about the issue

Notably, in the JSDoc version, using a non-type import removes the error:

import * as NS from "./namespace";

However, this causes a runtime import that's only used for type information.

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions