diff --git a/types/jotform-css.js/index.d.ts b/types/jotform-css.js/index.d.ts index 3b748fc176..d24e4d5458 100644 --- a/types/jotform-css.js/index.d.ts +++ b/types/jotform-css.js/index.d.ts @@ -3,15 +3,18 @@ // Definitions by: Peter van der Woude // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +declare global { + const cssjs: CssJsConstructor +} -/** - * Thid doesn't get used in the way I intended - */ -export function cssjs() : CssJs +export interface CssJsConstructor { + new (): CssJs; +} + +export const cssjs : CssJsConstructor; +export default cssjs; export interface CssJs { - /** * Parses given css string, and returns css object * keys as selectors and values are css rules diff --git a/types/jotform-css.js/jotform-css.js-global-tests.ts b/types/jotform-css.js/jotform-css.js-global-tests.ts new file mode 100644 index 0000000000..95cb5f6be0 --- /dev/null +++ b/types/jotform-css.js/jotform-css.js-global-tests.ts @@ -0,0 +1,5 @@ +function addNamespace(cssString: string): string { + const parser = new cssjs(); + const parsed = parser.applyNamespacing(cssString, "#id1"); + return parser.getCSSForEditor(parsed); +} diff --git a/types/jotform-css.js/jotform-css.js-module-tests.ts b/types/jotform-css.js/jotform-css.js-module-tests.ts new file mode 100644 index 0000000000..7f42f0275c --- /dev/null +++ b/types/jotform-css.js/jotform-css.js-module-tests.ts @@ -0,0 +1,9 @@ +import cssjsParser = require("jotform-css.js"); + +function addNamespace(cssString: string): string { + const parser = new cssjsParser.cssjs(); + let parsed = parser.parseCSS(cssString); + parsed = parser.applyNamespacing(parsed, "#id1"); + const css = parser.getCSSForEditor(parsed); + return css; +} diff --git a/types/jotform-css.js/jotform-css.js-tests.ts b/types/jotform-css.js/jotform-css.js-tests.ts index 688fa13112..ad2b619a10 100644 --- a/types/jotform-css.js/jotform-css.js-tests.ts +++ b/types/jotform-css.js/jotform-css.js-tests.ts @@ -1,17 +1,6 @@ -let cssjsGlobal = require("jotform-css.js/css.js") -import { CssJs } from "./index" - -// not all interface methods tested here, below is a sample of code that I've actually used -class TestParser { - public parse(cssString: string): string { - const parser = new cssjsGlobal.cssjs() as CssJs - - let parsed = parser.parseCSS(cssString) - parsed = parser.applyNamespacing(parsed, "#id1") - let css = parser.getCSSForEditor(parsed) - return css - } +// DefinitelyTyped scripts are forcing me to have this, I don't need or want this file +function addNamespace2(cssString: string): string { + const parser = new cssjs(); + const parsed = parser.applyNamespacing(cssString, "#id1"); + return parser.getCSSForEditor(parsed); } - -let parsingTest = new TestParser() -let css = parsingTest.parse(".foo { background-color: red }") diff --git a/types/jotform-css.js/tsconfig.json b/types/jotform-css.js/tsconfig.json index 2e6cc5a4f5..bae12b9a2c 100644 --- a/types/jotform-css.js/tsconfig.json +++ b/types/jotform-css.js/tsconfig.json @@ -18,6 +18,8 @@ }, "files": [ "index.d.ts", - "jotform-css.js-tests.ts" + "jotform-css.js-tests.ts", + "jotform-css.js-global-tests.ts", + "jotform-css.js-module-tests.ts" ] } diff --git a/types/jotform-css.js/tslint.json b/types/jotform-css.js/tslint.json index 44e1713d82..f93cf8562a 100644 --- a/types/jotform-css.js/tslint.json +++ b/types/jotform-css.js/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": true, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": true, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" }