diff --git a/tests/baselines/reference/intersectionSatisfiesConstraint.js b/tests/baselines/reference/intersectionSatisfiesConstraint.js new file mode 100644 index 0000000000000..e0fcbc6e90944 --- /dev/null +++ b/tests/baselines/reference/intersectionSatisfiesConstraint.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/intersectionSatisfiesConstraint.ts] //// + +//// [intersectionSatisfiesConstraint.ts] +interface FirstInterface { + commonProperty: number +} + +interface SecondInterface { + commonProperty: number +} + +const myFirstFunction = (param1: T) => { + const newParam: T & { otherProperty: number } = Object.assign(param1, { otherProperty: 3 }) + mySecondFunction(newParam) +} + +const mySecondFunction = (newParam: T) => { + return newParam +} + + +//// [intersectionSatisfiesConstraint.js] +"use strict"; +var myFirstFunction = function (param1) { + var newParam = Object.assign(param1, { otherProperty: 3 }); + mySecondFunction(newParam); +}; +var mySecondFunction = function (newParam) { + return newParam; +}; diff --git a/tests/baselines/reference/intersectionSatisfiesConstraint.symbols b/tests/baselines/reference/intersectionSatisfiesConstraint.symbols new file mode 100644 index 0000000000000..3c2153413c733 --- /dev/null +++ b/tests/baselines/reference/intersectionSatisfiesConstraint.symbols @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/intersectionSatisfiesConstraint.ts] //// + +=== intersectionSatisfiesConstraint.ts === +interface FirstInterface { +>FirstInterface : Symbol(FirstInterface, Decl(intersectionSatisfiesConstraint.ts, 0, 0)) + + commonProperty: number +>commonProperty : Symbol(FirstInterface.commonProperty, Decl(intersectionSatisfiesConstraint.ts, 0, 26)) +} + +interface SecondInterface { +>SecondInterface : Symbol(SecondInterface, Decl(intersectionSatisfiesConstraint.ts, 2, 1)) + + commonProperty: number +>commonProperty : Symbol(SecondInterface.commonProperty, Decl(intersectionSatisfiesConstraint.ts, 4, 27)) +} + +const myFirstFunction = (param1: T) => { +>myFirstFunction : Symbol(myFirstFunction, Decl(intersectionSatisfiesConstraint.ts, 8, 5)) +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 8, 25)) +>FirstInterface : Symbol(FirstInterface, Decl(intersectionSatisfiesConstraint.ts, 0, 0)) +>SecondInterface : Symbol(SecondInterface, Decl(intersectionSatisfiesConstraint.ts, 2, 1)) +>param1 : Symbol(param1, Decl(intersectionSatisfiesConstraint.ts, 8, 69)) +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 8, 25)) + + const newParam: T & { otherProperty: number } = Object.assign(param1, { otherProperty: 3 }) +>newParam : Symbol(newParam, Decl(intersectionSatisfiesConstraint.ts, 9, 9)) +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 8, 25)) +>otherProperty : Symbol(otherProperty, Decl(intersectionSatisfiesConstraint.ts, 9, 25)) +>Object.assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>param1 : Symbol(param1, Decl(intersectionSatisfiesConstraint.ts, 8, 69)) +>otherProperty : Symbol(otherProperty, Decl(intersectionSatisfiesConstraint.ts, 9, 75)) + + mySecondFunction(newParam) +>mySecondFunction : Symbol(mySecondFunction, Decl(intersectionSatisfiesConstraint.ts, 13, 5)) +>newParam : Symbol(newParam, Decl(intersectionSatisfiesConstraint.ts, 9, 9)) +} + +const mySecondFunction = (newParam: T) => { +>mySecondFunction : Symbol(mySecondFunction, Decl(intersectionSatisfiesConstraint.ts, 13, 5)) +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 13, 26)) +>commonProperty : Symbol(commonProperty, Decl(intersectionSatisfiesConstraint.ts, 13, 37)) +>otherProperty : Symbol(otherProperty, Decl(intersectionSatisfiesConstraint.ts, 13, 61)) +>newParam : Symbol(newParam, Decl(intersectionSatisfiesConstraint.ts, 13, 87)) +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 13, 26)) + + return newParam +>newParam : Symbol(newParam, Decl(intersectionSatisfiesConstraint.ts, 13, 87)) +} + diff --git a/tests/baselines/reference/intersectionSatisfiesConstraint.types b/tests/baselines/reference/intersectionSatisfiesConstraint.types new file mode 100644 index 0000000000000..49e5eda86e073 --- /dev/null +++ b/tests/baselines/reference/intersectionSatisfiesConstraint.types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/intersectionSatisfiesConstraint.ts] //// + +=== intersectionSatisfiesConstraint.ts === +interface FirstInterface { + commonProperty: number +>commonProperty : number +} + +interface SecondInterface { + commonProperty: number +>commonProperty : number +} + +const myFirstFunction = (param1: T) => { +>myFirstFunction : (param1: T) => void +>(param1: T) => { const newParam: T & { otherProperty: number } = Object.assign(param1, { otherProperty: 3 }) mySecondFunction(newParam)} : (param1: T) => void +>param1 : T + + const newParam: T & { otherProperty: number } = Object.assign(param1, { otherProperty: 3 }) +>newParam : T & { otherProperty: number; } +>otherProperty : number +>Object.assign(param1, { otherProperty: 3 }) : T & { otherProperty: number; } +>Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } +>Object : ObjectConstructor +>assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } +>param1 : T +>{ otherProperty: 3 } : { otherProperty: number; } +>otherProperty : number +>3 : 3 + + mySecondFunction(newParam) +>mySecondFunction(newParam) : { commonProperty: number; otherProperty: number; } +>mySecondFunction : (newParam: T) => T +>newParam : (FirstInterface | SecondInterface) & { otherProperty: number; } +} + +const mySecondFunction = (newParam: T) => { +>mySecondFunction : (newParam: T) => T +>(newParam: T) => { return newParam} : (newParam: T) => T +>commonProperty : number +>otherProperty : number +>newParam : T + + return newParam +>newParam : T +} + diff --git a/tests/cases/compiler/intersectionSatisfiesConstraint.ts b/tests/cases/compiler/intersectionSatisfiesConstraint.ts new file mode 100644 index 0000000000000..69d76acc595cd --- /dev/null +++ b/tests/cases/compiler/intersectionSatisfiesConstraint.ts @@ -0,0 +1,19 @@ +// @strict: true +// @lib: esnext + +interface FirstInterface { + commonProperty: number +} + +interface SecondInterface { + commonProperty: number +} + +const myFirstFunction = (param1: T) => { + const newParam: T & { otherProperty: number } = Object.assign(param1, { otherProperty: 3 }) + mySecondFunction(newParam) +} + +const mySecondFunction = (newParam: T) => { + return newParam +}