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

How to hint possible values for a function parameter from an existing map? #159

Open
thany opened this issue May 13, 2022 · 0 comments
Open

Comments

@thany
Copy link

thany commented May 13, 2022

  • VS Code Version: 1.67
  • SCSS IntelliSense Version: 0.10.0
  • Operating System: Windows 10

Reproducible Case:

$brand-colors: (
  dark-blue:         #374c63,
  blue:              #0055a0,
  // ...
);

@function brand-color($name) {
  @if map-has-key($brand-colors, $name) {
    @return map-get($brand-colors, $name);
  }
  @else {
    @warn 'Brand color ' $name ' not found';
    @return 'unset';
  }
}

$color: brand-color(); // <-- Which $name are allowed?..

Steps to Reproduce:

  1. Use the code above
  2. Try intellisense on the function parameter
  3. Observe how it doesn't (and currently, cannot) know which values are permitted.

I would like to be able to hint to SCSS Intellisense what sort of values are permitted to pass into brand-color in the $name parameter. I want to populate that list of hints with the keys from an exisiting map, which is $brand-colors in the above example.

I was thinking JSdoc-style hints:

/// Description of brand-colors and whatall.
/// @param {keyof $brand-colors} $name The name of a color.
/// @returns {string} A color.
@function brand-color($name) {
  // ...
}

This could be enough information to provide such hints. I know Typescript (and Javascript to an extend) can do this, so I don't know why any other language couldn't do the same.

Sound good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant