dist/util/type-generator/get-type-name.js
function getTypeName(namespace, type) {
    let namespaceName = namespace.fullName;
    let finalName;
    for (let title of type.titles) {
        let name = titleToTypeName(namespaceName, title);
        if (finalName) {
            if (name[1]) {
                // An explicit type name, so make sure it isn't masking anything
                if (finalName[1] && name[0] !== finalName[0]) {
                    // Previous explicit name from another title is different
                    throw new Error(title + '\'s override to ' + name[0]
                        + ' would shadow explicit name of ' + finalName[0]);
                }
                // Otherwise take this name since it either is the same, or overrides
                // a non-explicit name
                finalName = name;
            }
            else if (!finalName[1] && name[0].length < finalName[0].length) {
                // Take the shorter of the generated names
                finalName = name;
            }
        }
        else {
            // First valid name
            finalName = name;
        }
    }
    if (finalName) {
        return finalName;
    }
    else {
        throw new Error('Unable to generate typename for ' + type.titles[0]);
    }
}
function getTypeName(namespace, type) {
    let namespaceName = namespace.fullName;
    let finalName;
    for (let title of type.titles) {
        let name = titleToTypeName(namespaceName, title);
        if (finalName) {
            if (name[1]) {
                // An explicit type name, so make sure it isn't masking anything
                if (finalName[1] && name[0] !== finalName[0]) {
                    // Previous explicit name from another title is different
                    throw new Error(title + '\'s override to ' + name[0]
                        + ' would shadow explicit name of ' + finalName[0]);
                }
                // Otherwise take this name since it either is the same, or overrides
                // a non-explicit name
                finalName = name;
            }
            else if (!finalName[1] && name[0].length < finalName[0].length) {
                // Take the shorter of the generated names
                finalName = name;
            }
        }
        else {
            // First valid name
            finalName = name;
        }
    }
    if (finalName) {
        return finalName;
    }
    else {
        throw new Error('Unable to generate typename for ' + type.titles[0]);
    }
}
function getTypeName ( namespace , type ) { let namespaceName = namespace . fullName ; let finalName ; for ( let title of type . titles ) { let name = titleToTypeName ( namespaceName , title ) ; if ( finalName ) { if ( name [ 1 ] ) { // An explicit type name, so make sure it isn't masking anything if ( finalName [ 1 ] && name [ 0 ] !== finalName [ 0 ] ) { // Previous explicit name from another title is different throw new Error ( title + '\'s override to ' + name [ 0 ] + ' would shadow explicit name of ' + finalName [ 0 ] ) ; } // Otherwise take this name since it either is the same, or overrides // a non-explicit name finalName = name ; } else if ( ! finalName [ 1 ] && name [ 0 ] . length < finalName [ 0 ] . length ) { // Take the shorter of the generated names finalName = name ; } } else { // First valid name finalName = name ; } } if ( finalName ) { return finalName ; } else { throw new Error ( 'Unable to generate typename for ' + type . titles [ 0 ] ) ; } }
No typings associated
No typings associated