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

Doc comment missing when generating declarations for const methods from js files #35933

Closed
karfau opened this issue Dec 31, 2019 · 2 comments · Fixed by #37594
Closed

Doc comment missing when generating declarations for const methods from js files #35933

karfau opened this issue Dec 31, 2019 · 2 comments · Fixed by #37594
Assignees
Labels
Domain: Comment Emit The issue relates to the emission of comments when compiling Domain: Declaration Emit The issue relates to the emission of d.ts files Domain: JavaScript The issue relates to JavaScript specifically Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this

Comments

@karfau
Copy link

karfau commented Dec 31, 2019

TypeScript Version: 3.8.0-dev.20191228

Search Terms: declarations js missing jsdoc

Code

index.js(!):

/**
 * const doc comment
 */
const x = (a) => {
    return '';
};

/**
 * function doc comment
 */
function b() {
    return 0;
}

module.exports = {x, b}

tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2015",
    "module": "none",
    "allowJs": true,
    "checkJs": true,
    "declaration": true,
    "outDir": "./",
    "strict": true,
    "noImplicitAny": false
  }
}

Expected behavior:
index.d.ts

/**
 * const doc comment
 */
export function x(a: any): string;
/**
 * second doc comment
 */
export function b(): number;

Actual behavior:
index.d.ts

export function x(a: any): string;
/**
 * second doc comment
 */
export function b(): number;

Playground Link: http://www.typescriptlang.org/play/?target=2&module=0&ts=3.8.0-dev.20191228&useJavaScript=true#code/PQKhCgAIUhbBPSATA9gY0mltYFMB2ALlCMOFvgM6GQAekAvJABQCGAlIwHyQDeUkQQCdchAK5D8kAOTSA3OAC+C8KAjRIlXBSTJ0mbHiIkyAMzH40hAJYopAI2ad+g4aIlSADAsXhwsFCQxABtcADpcWgAHFCFCSkY+WgAaSHtFIA

Related Issues: #22037 #5550

Current workaround:
Converting those methods to the function syntax, solves the issue for now.

@DanielRosenwasser DanielRosenwasser added Domain: Comment Emit The issue relates to the emission of comments when compiling Domain: Declaration Emit The issue relates to the emission of d.ts files Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this labels Dec 31, 2019
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.9.0 milestone Dec 31, 2019
@DanielRosenwasser DanielRosenwasser added the Domain: JavaScript The issue relates to JavaScript specifically label Dec 31, 2019
@jeanp413
Copy link
Contributor

jeanp413 commented Jan 1, 2020

This is also fixed by #30253

@karfau
Copy link
Author

karfau commented Jan 11, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Comment Emit The issue relates to the emission of comments when compiling Domain: Declaration Emit The issue relates to the emission of d.ts files Domain: JavaScript The issue relates to JavaScript specifically Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this
Projects
None yet
4 participants