Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating Type Definitions from Javascript is blocked by requiring private name #38382

Closed
stephenash opened this issue May 7, 2020 · 1 comment
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status. Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@stephenash
Copy link

TypeScript Version: 3.8.3, 4.0.0-dev.20200506

Search Terms:

  • Declaration emit for this file requires using private name
  • An explicit type annotation may unblock declaration emit
  • Static class members

Code

// that-hard-math-static.js
/**
 * @class
 */
var ThatHardMathStatic = {};

/**
 * @memberof ThatHardMathStatic
 * 
 * @param {number} a
 * @param {number} b
 */
ThatHardMathStatic.add = function(a, b) {
  return a + b;
}

module.exports = ThatHardMathStatic;

// index.js
var ThatHardMathStatic = require('./that-hard-math-static.js');

module.exports = { ThatHardMathStatic: ThatHardMathStatic };

Expected behavior:
Creating declarations works

Actual behavior:

index.js:1:1 - error TS9006: Declaration emit for this file requires using private name 'ThatHardMathStatic' from module '"/home/runner/BitterApprehensivePdf/that-hard-math-static"'. An explicit type annotation may unblock declaration emit.

1 var ThatHardMathStatic = require('./that-hard-math-static.js');
  ~~~
// that-hard-math-static.d.ts
export declare function add(a: number, b: number): number;

Looks like the add function was exported as a top level export instead of inside of a class/object.

Playground Link: https://repl.it/@stephenash/BitterApprehensivePdf
Open shell and run npm run build to trigger error

Related Issues:

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label May 8, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.0 milestone May 8, 2020
@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Aug 31, 2020
@weswigham
Copy link
Member

This no longer repros in our latest builds (I'm pretty sure another, more recent report was essentially the same thing and got fixed). ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status. Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

3 participants