diff --git a/types/infobox-parser/index.d.ts b/types/infobox-parser/index.d.ts new file mode 100644 index 0000000000..8642786caf --- /dev/null +++ b/types/infobox-parser/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for infobox-parser 3.3 +// Project: https://github.com/dijs/infobox-parser#readme +// Definitions by: Jeff Held +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface ParseOptions { + simplifyDataValues?: boolean; +} + +interface ParseResult { + general: any; + lists: any[]; + tables: any[]; +} + +declare function infobox_parser( + source: string, + options?: ParseOptions +): ParseResult; + +export = infobox_parser; diff --git a/types/infobox-parser/infobox-parser-tests.ts b/types/infobox-parser/infobox-parser-tests.ts new file mode 100644 index 0000000000..5cd0421ccf --- /dev/null +++ b/types/infobox-parser/infobox-parser-tests.ts @@ -0,0 +1,19 @@ +import parseInfo = require("infobox-parser"); + +interface Hero { + name: string; + hero: boolean; +} + +const { name, hero }: Hero = parseInfo(` +{{Infobox Batman +|name = Bruce Wayne +|hero = y +}}`).general; +/* Outputs { + general: { + hero: true, + name: 'Bruce Wayne' + } +} +*/ diff --git a/types/infobox-parser/tsconfig.json b/types/infobox-parser/tsconfig.json new file mode 100644 index 0000000000..dce6794d40 --- /dev/null +++ b/types/infobox-parser/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "infobox-parser-tests.ts"] +} diff --git a/types/infobox-parser/tslint.json b/types/infobox-parser/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/infobox-parser/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }