Add type definitions for insert-css (#31263)

* Add type definitions for insert-css

* Correct indentation in insert-css-tests.ts

* Make createElement calls consistent

* Use single quotes in import
This commit is contained in:
Heye 2018-12-18 00:06:50 +01:00 committed by Nathan Shively-Sanders
parent 5b5759e17b
commit 1935ac55bc
4 changed files with 72 additions and 0 deletions

18
types/insert-css/index.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
// Type definitions for insert-css 2.0
// Project: https://github.com/substack/insert-css
// Definitions by: Heye Vöcking <https://github.com/hvoecking>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface InsertCssOptions {
container?: HTMLElement;
prepend?: boolean;
}
export interface InsertCssStyleElement extends HTMLStyleElement {
styleSheet?: CSSStyleSheet;
}
export function insertCss(
css: string,
options?: InsertCssOptions,
): InsertCssStyleElement;

View File

@ -0,0 +1,27 @@
import { insertCss } from 'insert-css';
insertCss('body{position:absolute}');
insertCss('body{position:absolute}', {});
insertCss('body{text-decoration:underline !important}', {
prepend: true,
});
insertCss('body{text-decoration:underline !important}', {
prepend: false,
});
insertCss('body{position:absolute}', {
container: document.createElement(''),
});
insertCss('body{text-decoration:underline !important}', {
prepend: true,
container: document.createElement(''),
});
insertCss('body{text-decoration:underline !important}', {
prepend: false,
container: document.createElement(''),
});

View File

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

View File

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