lib/index.js
function getElementsMessages(elements) {
    return elements
        .map(function (element) {
        var msg = {};
        if (element.attributes) {
            element.attributes.properties.forEach(function (attr) {
                if (!ts.isJsxAttribute(attr) || !attr.initializer) {
                    // Either JsxSpreadAttribute, or JsxAttribute without initializer.
                    return;
                }
                var key = attr.name.text;
                var init = attr.initializer;
                var text;
                if (ts.isStringLiteral(init)) {
                    text = init.text;
                }
                else if (ts.isJsxExpression(init)) {
                    if (init.expression &&
                        (ts.isStringLiteral(init.expression) ||
                            ts.isNoSubstitutionTemplateLiteral(init.expression))) {
                        text = init.expression.text;
                    }
                    else {
                        // Either the JsxExpression has no expression (?)
                        // or a non-StringLiteral expression.
                        return;
                    }
                }
                else {
                    // Should be a StringLiteral or JsxExpression, but it's not!
                    return;
                }
                copyIfMessageKey(msg, key, text);
            });
        }
        return isValidMessage(msg) ? msg : null;
    })
        .filter(notNull);
}
function getElementsMessages(elements) {
    return elements
        .map(function (element) {
        var msg = {};
        if (element.attributes) {
            element.attributes.properties.forEach(function (attr) {
                if (!ts.isJsxAttribute(attr) || !attr.initializer) {
                    // Either JsxSpreadAttribute, or JsxAttribute without initializer.
                    return;
                }
                var key = attr.name.text;
                var init = attr.initializer;
                var text;
                if (ts.isStringLiteral(init)) {
                    text = init.text;
                }
                else if (ts.isJsxExpression(init)) {
                    if (init.expression &&
                        (ts.isStringLiteral(init.expression) ||
                            ts.isNoSubstitutionTemplateLiteral(init.expression))) {
                        text = init.expression.text;
                    }
                    else {
                        // Either the JsxExpression has no expression (?)
                        // or a non-StringLiteral expression.
                        return;
                    }
                }
                else {
                    // Should be a StringLiteral or JsxExpression, but it's not!
                    return;
                }
                copyIfMessageKey(msg, key, text);
            });
        }
        return isValidMessage(msg) ? msg : null;
    })
        .filter(notNull);
}
function getElementsMessages ( elements ) { return elements . map ( function ( element ) { var msg = { } ; if ( element . attributes ) { element . attributes . properties . forEach ( function ( attr ) { if ( ! ts . isJsxAttribute ( attr ) || ! attr . initializer ) { // Either JsxSpreadAttribute, or JsxAttribute without initializer. return ; } var key = attr . name . text ; var init = attr . initializer ; var text ; if ( ts . isStringLiteral ( init ) ) { text = init . text ; } else if ( ts . isJsxExpression ( init ) ) { if ( init . expression && ( ts . isStringLiteral ( init . expression ) || ts . isNoSubstitutionTemplateLiteral ( init . expression ) ) ) { text = init . expression . text ; } else { // Either the JsxExpression has no expression (?) // or a non-StringLiteral expression. return ; } } else { // Should be a StringLiteral or JsxExpression, but it's not! return ; } copyIfMessageKey ( msg , key , text ) ; } ) ; } return isValidMessage ( msg ) ? msg : null ; } ) . filter ( notNull ) ; }
convert JsxOpeningLikeElements to Message maps
@param elements
convert JsxOpeningLikeElements to Message maps