//// [tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes02.tsx] ////

//// [file.tsx]
/// <reference path="/.lib/react.d.ts" />

import React = require('react')

declare function log(...args: any[]): void;

export interface ClickableProps {
    children?: string;
    className?: string;
}

export interface ButtonProps extends ClickableProps {
    onClick: (k: "left" | "right") => void;
}

export interface LinkProps extends ClickableProps {
    goTo: "home" | "contact";
}

export function MainButton(buttonProps: ButtonProps): JSX.Element;
export function MainButton(linkProps: LinkProps): JSX.Element;
export function MainButton(props: ButtonProps | LinkProps): JSX.Element {
    const linkProps = props as LinkProps;
    if(linkProps.goTo) {
        return this._buildMainLink(props);
    }

    return this._buildMainButton(props);
}

const b0 = <MainButton {...{onClick: (k) => {log(k)}}} extra />;  // k has type "left" | "right"
const b2 = <MainButton onClick={(k)=>{log(k)}} extra />;  // k has type "left" | "right"
const b3 = <MainButton {...{goTo:"home"}} extra />;  // goTo has type"home" | "contact"
const b4 = <MainButton goTo="home" extra />;  // goTo has type "home" | "contact"

export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined }
const c1 = <NoOverload  {...{onClick: (k) => {log(k)}}} extra />;  // k has type any

export function NoOverload1(linkProps: LinkProps): JSX.Element { return undefined }
const d1 = <NoOverload1 {...{goTo:"home"}} extra  />;  // goTo has type "home" | "contact"


//// [file.jsx]
"use strict";
/// <reference path="/.lib/react.d.ts" />
Object.defineProperty(exports, "__esModule", { value: true });
exports.MainButton = MainButton;
exports.NoOverload = NoOverload;
exports.NoOverload1 = NoOverload1;
const React = require("react");
function MainButton(props) {
    const linkProps = props;
    if (linkProps.goTo) {
        return this._buildMainLink(props);
    }
    return this._buildMainButton(props);
}
const b0 = <MainButton {...{ onClick: (k) => { log(k); } }} extra/>; // k has type "left" | "right"
const b2 = <MainButton onClick={(k) => { log(k); }} extra/>; // k has type "left" | "right"
const b3 = <MainButton {...{ goTo: "home" }} extra/>; // goTo has type"home" | "contact"
const b4 = <MainButton goTo="home" extra/>; // goTo has type "home" | "contact"
function NoOverload(buttonProps) { return undefined; }
const c1 = <NoOverload {...{ onClick: (k) => { log(k); } }} extra/>; // k has type any
function NoOverload1(linkProps) { return undefined; }
const d1 = <NoOverload1 {...{ goTo: "home" }} extra/>; // goTo has type "home" | "contact"
