From 29f196223f58b366b093eb275bdd9ed49aeefbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Mon, 2 Mar 2020 19:49:52 +0100 Subject: [PATCH] feat(karma-json-preprocessor): new type definition (#42738) - type definitions - tests https://github.com/mjeanroy/karma-json-preprocessor#configuration Thanks! --- types/karma-json-preprocessor/index.d.ts | 31 +++++++++++++++++++ .../karma-json-preprocessor-tests.ts | 20 ++++++++++++ types/karma-json-preprocessor/tsconfig.json | 23 ++++++++++++++ types/karma-json-preprocessor/tslint.json | 1 + 4 files changed, 75 insertions(+) create mode 100644 types/karma-json-preprocessor/index.d.ts create mode 100644 types/karma-json-preprocessor/karma-json-preprocessor-tests.ts create mode 100644 types/karma-json-preprocessor/tsconfig.json create mode 100644 types/karma-json-preprocessor/tslint.json diff --git a/types/karma-json-preprocessor/index.d.ts b/types/karma-json-preprocessor/index.d.ts new file mode 100644 index 0000000000..b3545d1106 --- /dev/null +++ b/types/karma-json-preprocessor/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for karma-json-preprocessor 0.3 +// Project: https://github.com/mjeanroy/karma-json-preprocessor#readme +// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.2 + +import 'karma'; + +declare module 'karma' { + interface ConfigOptions { + /** + * see {@link https://github.com/mjeanroy/karma-json-preprocessor#configuration-1} + */ + jsonPreprocessor?: JsonPreprocessorOptions; + } + + /** + * Default global variable name is by default `__json__`, + * but you can override it with your own name in karma configuration: + */ + interface JsonPreprocessorOptions { + /** + * @default '__json__' + */ + varName?: string; + /** + * @default '' + */ + stripPrefix?: string; + } +} diff --git a/types/karma-json-preprocessor/karma-json-preprocessor-tests.ts b/types/karma-json-preprocessor/karma-json-preprocessor-tests.ts new file mode 100644 index 0000000000..f22bae103f --- /dev/null +++ b/types/karma-json-preprocessor/karma-json-preprocessor-tests.ts @@ -0,0 +1,20 @@ +import karma = require('karma'); + +// Mocha reporter options tests +const mochaReporter: karma.JsonPreprocessorOptions = { + varName: '$json', + stripPrefix: 'prefix', +}; + +module.exports = (config: karma.Config) => { + config.set({ + preprocessors: { + '**/*.json': ['json'], + }, + files: ['**/*.js', '**/*.json'], + jsonPreprocessor: { + varName: '$json', + stripPrefix: 'prefix', + }, + }); +}; diff --git a/types/karma-json-preprocessor/tsconfig.json b/types/karma-json-preprocessor/tsconfig.json new file mode 100644 index 0000000000..6982d26ec7 --- /dev/null +++ b/types/karma-json-preprocessor/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "karma-json-preprocessor-tests.ts" + ] +} diff --git a/types/karma-json-preprocessor/tslint.json b/types/karma-json-preprocessor/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/karma-json-preprocessor/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }