diff --git a/tests/baselines/reference/intersectionTypeInference1.js b/tests/baselines/reference/intersectionTypeInference1.js new file mode 100644 index 00000000000..f4ad4da608b --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference1.js @@ -0,0 +1,17 @@ +//// [intersectionTypeInference1.ts] +// Repro from #8801 + +function alert(s: string) {} + +const parameterFn = (props:{store:string}) => alert(props.store) +const brokenFunction = (f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o +export const Form3 = brokenFunction(parameterFn)({store: "hello"}) + + +//// [intersectionTypeInference1.js] +// Repro from #8801 +"use strict"; +function alert(s) { } +var parameterFn = function (props) { return alert(props.store); }; +var brokenFunction = function (f) { return function (o) { return o; }; }; +exports.Form3 = brokenFunction(parameterFn)({ store: "hello" }); diff --git a/tests/baselines/reference/intersectionTypeInference1.symbols b/tests/baselines/reference/intersectionTypeInference1.symbols new file mode 100644 index 00000000000..f45d4fbd5b8 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference1.symbols @@ -0,0 +1,33 @@ +=== tests/cases/compiler/intersectionTypeInference1.ts === +// Repro from #8801 + +function alert(s: string) {} +>alert : Symbol(alert, Decl(intersectionTypeInference1.ts, 0, 0)) +>s : Symbol(s, Decl(intersectionTypeInference1.ts, 2, 15)) + +const parameterFn = (props:{store:string}) => alert(props.store) +>parameterFn : Symbol(parameterFn, Decl(intersectionTypeInference1.ts, 4, 5)) +>props : Symbol(props, Decl(intersectionTypeInference1.ts, 4, 21)) +>store : Symbol(store, Decl(intersectionTypeInference1.ts, 4, 28)) +>alert : Symbol(alert, Decl(intersectionTypeInference1.ts, 0, 0)) +>props.store : Symbol(store, Decl(intersectionTypeInference1.ts, 4, 28)) +>props : Symbol(props, Decl(intersectionTypeInference1.ts, 4, 21)) +>store : Symbol(store, Decl(intersectionTypeInference1.ts, 4, 28)) + +const brokenFunction = (f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o +>brokenFunction : Symbol(brokenFunction, Decl(intersectionTypeInference1.ts, 5, 5)) +>OwnProps : Symbol(OwnProps, Decl(intersectionTypeInference1.ts, 5, 24)) +>f : Symbol(f, Decl(intersectionTypeInference1.ts, 5, 34)) +>p : Symbol(p, Decl(intersectionTypeInference1.ts, 5, 38)) +>dispatch : Symbol(dispatch, Decl(intersectionTypeInference1.ts, 5, 42)) +>OwnProps : Symbol(OwnProps, Decl(intersectionTypeInference1.ts, 5, 24)) +>o : Symbol(o, Decl(intersectionTypeInference1.ts, 5, 85)) +>OwnProps : Symbol(OwnProps, Decl(intersectionTypeInference1.ts, 5, 24)) +>o : Symbol(o, Decl(intersectionTypeInference1.ts, 5, 85)) + +export const Form3 = brokenFunction(parameterFn)({store: "hello"}) +>Form3 : Symbol(Form3, Decl(intersectionTypeInference1.ts, 6, 12)) +>brokenFunction : Symbol(brokenFunction, Decl(intersectionTypeInference1.ts, 5, 5)) +>parameterFn : Symbol(parameterFn, Decl(intersectionTypeInference1.ts, 4, 5)) +>store : Symbol(store, Decl(intersectionTypeInference1.ts, 6, 50)) + diff --git a/tests/baselines/reference/intersectionTypeInference1.types b/tests/baselines/reference/intersectionTypeInference1.types new file mode 100644 index 00000000000..b74b2d2a453 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference1.types @@ -0,0 +1,41 @@ +=== tests/cases/compiler/intersectionTypeInference1.ts === +// Repro from #8801 + +function alert(s: string) {} +>alert : (s: string) => void +>s : string + +const parameterFn = (props:{store:string}) => alert(props.store) +>parameterFn : (props: { store: string; }) => void +>(props:{store:string}) => alert(props.store) : (props: { store: string; }) => void +>props : { store: string; } +>store : string +>alert(props.store) : void +>alert : (s: string) => void +>props.store : string +>props : { store: string; } +>store : string + +const brokenFunction = (f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o +>brokenFunction : (f: (p: { dispatch: number; } & OwnProps) => void) => (o: OwnProps) => OwnProps +>(f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o : (f: (p: { dispatch: number; } & OwnProps) => void) => (o: OwnProps) => OwnProps +>OwnProps : OwnProps +>f : (p: { dispatch: number; } & OwnProps) => void +>p : { dispatch: number; } & OwnProps +>dispatch : number +>OwnProps : OwnProps +>(o: OwnProps) => o : (o: OwnProps) => OwnProps +>o : OwnProps +>OwnProps : OwnProps +>o : OwnProps + +export const Form3 = brokenFunction(parameterFn)({store: "hello"}) +>Form3 : { store: string; } +>brokenFunction(parameterFn)({store: "hello"}) : { store: string; } +>brokenFunction(parameterFn) : (o: { store: string; }) => { store: string; } +>brokenFunction : (f: (p: { dispatch: number; } & OwnProps) => void) => (o: OwnProps) => OwnProps +>parameterFn : (props: { store: string; }) => void +>{store: "hello"} : { store: string; } +>store : string +>"hello" : string + diff --git a/tests/cases/compiler/intersectionTypeInference1.ts b/tests/cases/compiler/intersectionTypeInference1.ts new file mode 100644 index 00000000000..c4d46800f0c --- /dev/null +++ b/tests/cases/compiler/intersectionTypeInference1.ts @@ -0,0 +1,7 @@ +// Repro from #8801 + +function alert(s: string) {} + +const parameterFn = (props:{store:string}) => alert(props.store) +const brokenFunction = (f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o +export const Form3 = brokenFunction(parameterFn)({store: "hello"})