(new definition) add mjml (mjml.io) types (#25217)

* add mjml (mjml.io) types

* update mjml definition, actually verify linter runs, be more explicit in re: error types

* mjml: int -> number.  why does lint pass w/ 'int'? ah well.

* per @plantain-00 CR
This commit is contained in:
Andrew Houghton
2018-04-24 16:21:17 -07:00
committed by Wesley Wigham
parent 8231b1a62a
commit fd5742930d
4 changed files with 63 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
// Type definitions for mjml 4.0
// Project: https://github.com/mjmlio/mjml
// Definitions by: aahoughton <https://github.com/aahoughton>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface MJMLParsingOpts {
fonts?: { [key: string]: string; };
keepComments?: boolean;
beautify?: boolean;
minify?: boolean;
validationLevel?: 'strict' | 'soft' | 'skip';
filePath?: boolean;
}
interface MJMLParseError {
line: number;
message: string;
tagName: string;
formattedMessage: string;
}
interface MJMLParseResults {
html: string;
errors: MJMLParseError[];
}
declare function mjml2html(inp: string, opts?: MJMLParsingOpts): MJMLParseResults;
export = mjml2html;
+10
View File
@@ -0,0 +1,10 @@
import mjml2html = require('mjml');
const simple_test = mjml2html("<mjml>");
const html = simple_test.html;
const errors = simple_test.errors;
let formattedMessage = errors[0].formattedMessage;
formattedMessage = "force string test";
const minimal_opts_test = mjml2html("<mjml>", {beautify: true});
const validation_level_test = mjml2html("<mjml>", {validationLevel: "strict"});
+23
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",
"mjml-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }