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

IntelliSense not working with @typedef #110980

Closed
tnorlund opened this issue Nov 19, 2020 · 3 comments
Closed

IntelliSense not working with @typedef #110980

tnorlund opened this issue Nov 19, 2020 · 3 comments
Assignees
Labels
javascript JavaScript support issues upstream-issue-linked This is an upstream issue that has been reported upstream

Comments

@tnorlund
Copy link

I'd like to use IntelliSense to use @typedef or be able to show given parameters.

IntelliSense

  • VSCode Version: 1.51.1
  • OS Version: Mac OS 11.0.1
/**
 * @typedef {Object} ParsedUser
 * @param {String} name The name of the user.
 * @param {String} email The email of the user.
 * @param {Number|String} userNumber The number of the user.
 */

/**
 * Gets the useful user data from the current Cognito user session.
 * @param {Object} CognitoUserSession The current cognito user session.
 * @returns {ParsedUser} The parsed user data.
 */
export function parseUser( CognitoUserSession ) {
  const { name, email, ...restOfUser } = CognitoUserSession.idToken.payload
  return {
    name: name, email: email, userNumber: restOfUser[`custom:UserNumber`]
  }
}
@mjbvz
Copy link
Collaborator

mjbvz commented Nov 19, 2020

What is the issue?

@mjbvz mjbvz added javascript JavaScript support issues info-needed Issue requires more information from poster labels Nov 19, 2020
@tnorlund
Copy link
Author

tnorlund commented Nov 19, 2020

The issue is that the returns from Intellisense does not show the information in the type definition.

Is there a better way to document this? I'd like to do something similar with a function that uses an object as a parameter.

/**
 * User library
 */
class User {
  /**
   * A user object.
   * @param {object} options
   * @param {String} options.name The name of the user.
   * @param {Number|String} [options.userNumber=`0`] The number of the user.
   */
  constructor( {
    name, email, userNumber = `0`, dateJoined = new Date(), numberTOS = `0`,
    numberFollows = `0`
  } ) {
    if ( !name ) throw Error( `Must give the user's name` )
    this.name = name
...

@mjbvz
Copy link
Collaborator

mjbvz commented Nov 19, 2020

It has the correct type so this is the currently the designed behavior .

Expanding typedefs like you want is tracked by microsoft/TypeScript#25784

@mjbvz mjbvz closed this as completed Nov 19, 2020
@mjbvz mjbvz added upstream-issue-linked This is an upstream issue that has been reported upstream and removed info-needed Issue requires more information from poster labels Nov 19, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues upstream-issue-linked This is an upstream issue that has been reported upstream
Projects
None yet
Development

No branches or pull requests

2 participants