Comments (5)
The following alternate generated syntax will give compile-time errors with hyphen values.
// This file is automatically generated.
// Please do not change this file!
const enum CssExports {
'item' = 'item',
'list' = 'list',
'root' = 'root',
'text' = 'text',
'text--small' = 'text--small',
'title' = 'title',
'title--small' = 'title--small',
}
declare const cssExports: typeof CssExports;
export = cssExports;
[tsl] ERROR in C:\javascript\my-component.tsx(28,33)
TS2339: Property 'titlae--small' does not exist on type 'typeof CssExports'.
Potential problems
const enum
can have problems with isolatedModules
from css-modules-typescript-loader.
@jahredhope I'm happy to make a PR + tests if you guys are willing to accept it.
If I put in the effort will this get merged?
from css-modules-typescript-loader.
I explored this option and it can fail in cases where users simply passed the entire styles
variable to another value.
ie. we're utilizing this in a project using Aurelia (with an aim to move slowly to React), so for our Aurelia components, we can't expose the CSS modules object to the templater of that particular framework.
@autoinject
@useView(PLATFORM.moduleName('./my-component.html'))
export class MyComponent {
private readonly styles = styles;
}
I'm going to close this.
from css-modules-typescript-loader.
Nevermind, I think I have a nice solution / patch to this problem.
We just define an index signature that returns void.
For example:
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
[key: string]: void; // <- this makes typos give you an error
'orb': string;
'orb-active-user': string;
'orb-exited-user': string;
'orb-list': string;
}
declare const cssExports: CssExports;
export = cssExports;
ERROR in components\entity-search\entity-search.tsx
components/entity-search/entity-search.tsx
[tsl] ERROR in components\entity-search\entity-search.tsx(945,7)
TS2322: Type 'void' is not assignable to type 'string'.
from css-modules-typescript-loader.
This approach has problems as pointed out by @MattsJones in his comment:
#29 (comment)
Needs further investigation.
from css-modules-typescript-loader.
Related Issues (20)
- Place css-modules-typescript-loader directly after css-loader in your webpack config HOT 1
- Mode 'verify' and tests do not run on Windows HOT 3
- Use with CRA without ejecting? HOT 2
- declare const instead of var
- Question: use generated TypeScript declaration in my React component. HOT 2
- Compatibility with modular-css
- Empty css.d.ts file HOT 2
- Cannot access directly the style from style object HOT 6
- Format output using Prettier
- style-loader docs is missing
- exporting of const=cssExports is redundant
- Support named exports
- Doesn't export fields with css-loader ^4.0.0 HOT 7
- npm file inclusion
- Cannot find module './Component.module.scss' and unused components
- Don't create typings files for non-named imports
- Definition file generated different in development compared to production mode
- Is it recommended to commit generated *.scss.d.ts files? HOT 1
- Generate app.d.css.ts instead of app.css.d.ts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css-modules-typescript-loader.