Merge pull request #33022 from djcsdy/cssesc

[cssesc] Add type definitions
This commit is contained in:
Mine Starks
2019-02-14 11:21:10 -08:00
committed by GitHub
4 changed files with 81 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import cssesc = require("cssesc");
// $ExpectType string
cssesc('Ich ♥ Bücher');
// $ExpectType string
cssesc('123a2b', {
isIdentifier: true
});
// $ExpectType string
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
quotes: 'single'
});
// $ExpectType string
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
quotes: 'double'
});
// $ExpectType string
cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
quotes: 'single',
wrap: true
});
// $ExpectType string
cssesc('lolwat"foo\'bar', {
escapeEverything: true
});
cssesc.options.escapeEverything = false;
// $ExpectType string
cssesc.version;

22
types/cssesc/index.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
// Type definitions for cssesc 3.0
// Project: https://mths.be/cssesc
// Definitions by: Daniel Cassidy <https://github.com/djcsdy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export = cssesc;
declare function cssesc(string: string, options?: Readonly<Partial<cssesc.Options>>): string;
declare namespace cssesc {
interface Options {
escapeEverything: boolean;
isIdentifier: boolean;
quotes: string;
wrap: boolean;
}
const options: Options;
const version: string;
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cssesc-tests.ts"
]
}

1
types/cssesc/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }