Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

1.7.0 no default export on typing file causes problems with importing style modules #68

Open
Joegrundman opened this issue Jul 20, 2018 · 3 comments

Comments

@Joegrundman
Copy link

Joegrundman commented Jul 20, 2018

As of version 1.7.0 and typescript 2.9.2 and contrary to the documentation, no default export is provided on the [styles].css.d.ts file

e.g. with a create-react-app new project

export interface IAppCss {
  'App': string;
  'logo': string;
  'logoSpin': string;
  'header': string;
  'title': string;
  'intro': string;
  'button': string;
}

export const locals: IAppCss;

this seems to cause some problems with importing the styles into the component with e.g.

import locals from './App.css

restoring the export default by changing

 return 'export interface ' + interfaceName + ' {\n' + interfaceProperties + '\n}\n\nexport const locals: ' + interfaceName + ';\n';

to

 return 'export interface ' + interfaceName + ' {\n' + interfaceProperties + '\n}\n\nexport const locals: ' + interfaceName + ';\n\nexport default locals;\n';

in typings-for-css-module-loader/lib/cssModuleToInterface.js line 79 restores what I imagine to be the desired behaviour.

Perhaps I am missing something?

@Joegrundman
Copy link
Author

no response... I am disabling this plugin as broken.

tbh I am of the opinion that CSS modules + typescript + this plugin has more cons than pros anyway. Even with a fix I am finding that to generate a css.d.ts file requires an npm restart, and then for the ts compiler to pick it up requires a second restart.

@immortal-tofu
Copy link

Encounters same issue... :(

@JasonDRZ
Copy link

So Bad!

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

No branches or pull requests

3 participants