
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
The package provides a convenient way to create a typescript enum for css classes in *.css
and *.scss
files for later use in typescript or javascript files. It does not require a bundler and can be used on directories or separate files.
Install it from npm using your preferred package manager, i.e.:
npm install css-types --save-dev
Create a custom script in your package.json file:
"scripts": {
"css-types": "css-types"
}
Then run it:
npm run css-types
You can also set it to watch mode:
"scripts": {
"css-types": "css-types --watch"
}
By default css-types
looks for the src
directory and walks it, creating typescript enums for every *.css
and *.scss
file it finds. To set a different directory for crawling simply pass its relative path:
"scripts": {
"css-types": "css-types --watch --directory=src/css"
},
It creates a typescript a *.style.ts
file containing enum with all style classes found in the stylesheet file as enum values *.css
and *.scss
file will receive.
For example, provided you have a stylesheet main.scss
with the following contents:
// Hypothetical main.css file.
.content {
color: pink;
.ads {
background: red;
}
}
Performing css-types
command will create main.style.ts
file with the following enum:
export enum Main {
Content = 'content',
Ads = 'ads',
}
Now it can be used in ts
:
import { Main } from './css/main.style';
document.getElementById('some-element-id').classList.add(Main.Content);
No need to worry about accidental renaming of css class that is used somewhere - as soon as types are updated and enum keys change, it will trigger an error if non-existant css classes are in use somewhere.
FAQs
Package for creating typings for stylesheet files.
The npm package css-types receives a total of 17 weekly downloads. As such, css-types popularity was classified as not popular.
We found that css-types demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.