mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 21:10:23 +00:00
Add type definitions for css-modules-loader-core (#33744)
This commit is contained in:
committed by
Wesley Wigham
parent
25e3419e81
commit
8146f41263
@@ -0,0 +1,24 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import Core, { Source } from "css-modules-loader-core";
|
||||
|
||||
const core = new Core();
|
||||
const emptyPlugins = new Core([]);
|
||||
const withPlugins = new Core([
|
||||
Core.values,
|
||||
Core.localByDefault,
|
||||
Core.extractImports,
|
||||
Core.scope
|
||||
]);
|
||||
const withDefaultPlugins = new Core(Core.defaultPlugins);
|
||||
|
||||
// $ExpectError
|
||||
const noArray = new Core(Core.values);
|
||||
|
||||
// Validating the source can be anything that has toString() defined
|
||||
const bufferSource: Source = new Buffer("str");
|
||||
|
||||
core.load("str").then(({ injectableSource, exportTokens }) => {
|
||||
const str: string = injectableSource;
|
||||
exportTokens["key"] = "value";
|
||||
});
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// Type definitions for css-modules-loader-core 1.1
|
||||
// Project: https://github.com/css-modules/css-modules-loader-core
|
||||
// Definitions by: Spencer Miskoviak <https://github.com/skovy>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
import { Plugin } from "postcss";
|
||||
|
||||
declare namespace Core {
|
||||
type Source =
|
||||
| string
|
||||
| {
|
||||
toString(): string;
|
||||
};
|
||||
|
||||
type PathFetcher = (
|
||||
file: string,
|
||||
relativeTo: string,
|
||||
depTrace: string
|
||||
) => void;
|
||||
|
||||
interface ExportTokens {
|
||||
[index: string]: string;
|
||||
}
|
||||
|
||||
interface Result {
|
||||
injectableSource: string;
|
||||
exportTokens: ExportTokens;
|
||||
}
|
||||
}
|
||||
|
||||
declare class Core {
|
||||
static values: Plugin<{}>;
|
||||
static localByDefault: Plugin<{}>;
|
||||
static extractImports: Plugin<{}>;
|
||||
static scope: Plugin<{}>;
|
||||
static defaultPlugins: Array<Plugin<{}>>;
|
||||
|
||||
constructor(plugins?: Array<Plugin<any>>);
|
||||
|
||||
load(
|
||||
source: Core.Source,
|
||||
sourcePath?: string,
|
||||
trace?: string,
|
||||
pathFetcher?: Core.PathFetcher
|
||||
): Promise<Core.Result>;
|
||||
}
|
||||
|
||||
export = Core;
|
||||
export as namespace Core;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"postcss": "7.x.x"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"css-modules-loader-core-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user