Skip to content

Declaration file for @implements of type specified in .d.ts file includes broken syntax #38640

Closed
@TimvdLippe

Description

@TimvdLippe

TypeScript Version: 4.0.0-dev.20200512

Search Terms: implements, jsdoc, declaration

Code

file.js:

/**
 * @implements {Global.Dispatcher}
 */
export class Dispatcher {
  foobar() {
    return 42;
  };
}

defs.d.ts:

declare namespace Global {
  export interface Dispatcher {
    foobar(): number;
  }
}

tsconfig.json:

{
  "compilerOptions": {
    "module": "esnext",
    "target": "esnext",
    "outDir": "lib",
    "declaration": true,
    "allowJs": true,
    "checkJs": true
  },
  "files": [
    "file.js",
    "defs.d.ts"
  ]
}

Expected behavior:
Output declaration file file.d.ts:

/**
 * @implements {Global.Dispatcher}
 */
export class Dispatcher implements Global.Dispatcher {
    foobar(): number;
}
export {};

Actual behavior:

declare const Dispatcher_base: undefined;
/**
 * @implements {Global.Dispatcher}
 */
export class Dispatcher implements Dispatcher_base {
    foobar(): number;
}
export {};

The syntax in this declaration file is broken and shows the following error:

'Dispatcher_base' refers to a value, but is being used as a type here.ts(2749)

Playground Link: n/a

Related Issues: #35629 implemented in #36292 CC @sandersn @dragomirtitian

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