-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initializes npm package. Configures husky, lint-staged, and prettier. Includes motivation in the README. Adds `.gitignore`.
- Loading branch information
Showing
6 changed files
with
1,098 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged --allow-empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# css-typed | ||
Basic TypeScript declaration generator for CSS files | ||
|
||
Basic TypeScript declaration generator for CSS files. | ||
|
||
## Motivation | ||
|
||
[typescript-plugin-css-modules] provides a great IDE experience, but cannot | ||
perform build-failing type-checking. Furthermore, the traditional TypeScript | ||
ambient module definition fails the `noUncheckedIndexedAccess` strict check and | ||
causes issues with typed ESLint rules. | ||
|
||
```ts | ||
// This does not provide strict typing | ||
declare module "*.module.css" { | ||
const classes: { [key: string]: string }; | ||
export default classes; // It also uses default export 😿 | ||
} | ||
``` | ||
|
||
[typed-css-modules] and [typed-scss-modules] exist, but the former does not have | ||
recent activity and the latter focuses on SCSS (and my current (2023) interests | ||
involve modern CSS only). Both depend on [css-modules-loader-core], which | ||
appears [abandoned][174]. | ||
|
||
Therefore, I wrote my own (very basic) implementation. | ||
|
||
<!-- prettier-ignore-start --> | ||
[typescript-plugin-css-modules]: https://www.npmjs.com/package/typescript-plugin-css-modules | ||
[typed-css-modules]: https://www.npmjs.com/package/typed-css-modules | ||
[typed-scss-modules]: https://www.npmjs.com/package/typed-scss-modules | ||
[css-modules-loader-core]: https://www.npmjs.com/package/css-modules-loader-core | ||
[174]: https://github.com/css-modules/css-modules-loader-core/issues/174 | ||
<!-- prettier-ignore-end --> |
Oops, something went wrong.