Skip to content

Commit

Permalink
🎉 Create project
Browse files Browse the repository at this point in the history
Initializes npm package. Configures husky, lint-staged, and prettier.
Includes motivation in the README. Adds `.gitignore`.
  • Loading branch information
connorjs committed Mar 24, 2023
1 parent 4d0d88b commit 947f9ba
Show file tree
Hide file tree
Showing 6 changed files with 1,098 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.idea/
4 changes: 4 additions & 0 deletions .husky/pre-commit
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
33 changes: 32 additions & 1 deletion README.md
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 -->
Loading

0 comments on commit 947f9ba

Please sign in to comment.