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

Add "deprecated" to unknown class names #185

Open
KurtGokhan opened this issue Dec 5, 2022 · 1 comment
Open

Add "deprecated" to unknown class names #185

KurtGokhan opened this issue Dec 5, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@KurtGokhan
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

Add deprecated option to allowUnknownClassnames option, in addition to true and false. Alternatively, there can be a new option named unknownClassnamesAsDeprecated.

This option adds JSDoc's @deprecated tag to Typescript index signature in the dts file, so that they are marked differently in IDEs, but not cause errors (e.g. they have strikethrough in VSCode).

Describe alternatives you've considered

I have been using this transformer before:

module.exports = (dts, { classes, logger }) => {
  var classNames = Object.keys(classes);

  return [
    '/* eslint-disable */',
    'declare let classes: {',
    '  /** @deprecated This class does not exist in the style file */',
    '  [key: string]: string;',
    `  ${classNames.map((x) => `'${x}': string;`).join('\n  ')}`,
    '};',
    'export default classes;',
    'export const __cssModule: true;',
    `export type AllClassNames = '${classNames.join("' | '")}';`,
  ].join('\n');
};

But it will be hard to maintain this in my codebase from now on since the new options are added (like goToDefinition).

Additional context

An example of how it looks in VSCode:

image

I can prepare a PR for this if you can decide on which option to use.

@mrmckeb mrmckeb added the enhancement New feature or request label Dec 5, 2022
@mrmckeb
Copy link
Owner

mrmckeb commented Dec 5, 2022

Hi there, this is a good suggestion - thanks. I'll give it a little thought, but I'm leaning towards the first option for now.

@mrmckeb mrmckeb self-assigned this Feb 18, 2023
@mrmckeb mrmckeb added this to the v5.0.0 milestone Mar 11, 2023
@mrmckeb mrmckeb added the help wanted Extra attention is needed label Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants