Skip to content

Add "deprecated" to unknown class names #185

Open
@KurtGokhan

Description

@KurtGokhan

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions