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

Refactors which in TS would generate a type annotation should generate jsdoc in JS #26306

Open
weswigham opened this issue Aug 8, 2018 · 2 comments
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript
Milestone

Comments

@weswigham
Copy link
Member

TypeScript Version: 3.1.0-dev.201xxxxx

Search Terms:

Code

// In TS
function x(): 42 {
  return /*extract to inner function*/42;
}
// In JS
// @ts-check
/**
 * @returns {42}
 */
function x() {
    return /*extract to inner function*/42;
}

Expected behavior:
Under ts-check, a refactoring should apply appropriate jsdocs to allow js to typecheck after a refactoring if it typechecked before it.

Actual behavior:
jsneedsdocs

Playground Link:

Related Issues:

@RyanCavanaugh
Copy link
Member

Is this only observable for literals and tuples?

@weswigham
Copy link
Member Author

weswigham commented Aug 8, 2018

Anywhere a contextual type is required for the expression to be given the correct type. Although this also applied to anything that makes a new declaration without an initializer, like some forms in the async refactor PR.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Committed The team has roadmapped this issue labels Aug 8, 2018
@RyanCavanaugh RyanCavanaugh added this to the Future milestone Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants