"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tryToReturnNull = exports.neverEnds = exports.showMyRealAge = exports.myRealAge = exports.anotherComplexObject = exports.complexObject = exports.userData = exports.userName = void 0;
const name = 'Mike';
exports.userName = {
    age: 99,
    name,
};
/**
 * Type-Safe definition eines Objects-
 *
 * Das Objekt hat zwei parameter: name + age
 */
exports.userData = {
    age: 99,
    name: 'Gerda',
};
/**
 * Das komplexe Object hat eine Callback als zweiten parameter
 */
exports.complexObject = {
    name: 'Mike',
    callback(age) {
        return `Age: ${age}`;
    },
};
exports.anotherComplexObject = {
    data: [4, 5, 6],
    name: 'Mike',
};
// - Union Types -------------------------------------------------------------------------------------------------------
exports.myRealAge = 99;
function showMyRealAge(age) {
    return typeof age === 'number' ? `N: ${age}` : `S: ${age}`;
}
exports.showMyRealAge = showMyRealAge;
// - never Type --------------------------------------------------------------------------------------------------------
/**
 * Die Funktion endet nie - deshalb der return type: never
 */
function neverEnds() {
    throw new Error('An error occurred!');
}
exports.neverEnds = neverEnds;
// - not nullable Types ------------------------------------------------------------------------------------------------
function tryToReturnNull(paramShouldNotBeNull) {
    // tslint:disable-next-line
    return paramShouldNotBeNull === 'Mike' ? paramShouldNotBeNull : null;
}
exports.tryToReturnNull = tryToReturnNull;
//# sourceMappingURL=objects_and_types.js.map