Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript typings #123

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { Plugin } from "postcss";

declare type GenerateScopedNameFunction = (
name: string,
filename: string,
css: string
) => string;

declare type LocalsConventionFunction = (
originalClassName: string,
generatedClassName: string,
inputFile: string
) => string;

declare class Loader {
constructor(root: string, plugins: Plugin[]);

fetch(
file: string,
relativeTo: string,
depTrace: string
): Promise<{ [key: string]: string }>;

finalSource?: string | undefined;
}

declare interface Options {
getJSON?(
cssFilename: string,
json: { [name: string]: string },
outputFilename?: string
): void;

localsConvention?:
| "camelCase"
| "camelCaseOnly"
| "dashes"
| "dashesOnly"
| LocalsConventionFunction;

scopeBehaviour?: "global" | "local";
globalModulePaths?: RegExp[];

generateScopedName?: string | GenerateScopedNameFunction;

hashPrefix?: string;
exportGlobals?: boolean;
root?: string;

Loader?: typeof Loader;
}

declare interface PostcssModulesPlugin {
(options: Options): Plugin;
postcss: true;
}

export = PostcssModulesPlugin;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "4.0.0",
"description": "PostCSS plugin to use CSS Modules everywhere",
"main": "build/index.js",
"types": "index.d.ts",
"keywords": [
"postcss",
"css",
Expand Down