Skip to content

TS JSDoc visibility error #41672

Open
Open
@hugomrdias

Description

@hugomrdias

TypeScript Version: 4.1.2

Search Terms:
An explicit type annotation may unblock declaration emit
private name

Code

https://codesandbox.io/s/tsc-ts-docs-visibility-repro-f73gw?file=/src/index.js

// @filename: base.js
class Base {
    constructor() {}
}

const BaseFactory = () => {
    return new Base();
};

BaseFactory.Base = Base;

module.exports = BaseFactory;

// @filename: index.js
/** @typedef {import('./base')} BaseFactory */

/**
 *
 * @param {InstanceType<BaseFactory["Base"]>} base
 */
const test = (base) => {
    return base;
};

Expected behavior:
No error from the compiler

Actual behavior:

src/index.js:7:1 - error TS9006: Declaration emit for this file requires using private name 'Base' from module '"/sandbox/src/base"'. An explicit type annotation may unblock declaration emit.

7 const test = (base) => {
  ~~~~~


Found 1 error.

Playground Link:
https://codesandbox.io/s/tsc-ts-docs-visibility-repro-f73gw?file=/src/index.js

Related Issues:
#37832
#41250

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