|
| 1 | +//// [tests/cases/compiler/intersectionSatisfiesConstraint.ts] //// |
| 2 | + |
| 3 | +=== intersectionSatisfiesConstraint.ts === |
| 4 | +interface FirstInterface { |
| 5 | +>FirstInterface : Symbol(FirstInterface, Decl(intersectionSatisfiesConstraint.ts, 0, 0)) |
| 6 | + |
| 7 | + commonProperty: number |
| 8 | +>commonProperty : Symbol(FirstInterface.commonProperty, Decl(intersectionSatisfiesConstraint.ts, 0, 26)) |
| 9 | +} |
| 10 | + |
| 11 | +interface SecondInterface { |
| 12 | +>SecondInterface : Symbol(SecondInterface, Decl(intersectionSatisfiesConstraint.ts, 2, 1)) |
| 13 | + |
| 14 | + commonProperty: number |
| 15 | +>commonProperty : Symbol(SecondInterface.commonProperty, Decl(intersectionSatisfiesConstraint.ts, 4, 27)) |
| 16 | +} |
| 17 | + |
| 18 | +const myFirstFunction = <T extends FirstInterface | SecondInterface>(param1: T) => { |
| 19 | +>myFirstFunction : Symbol(myFirstFunction, Decl(intersectionSatisfiesConstraint.ts, 8, 5)) |
| 20 | +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 8, 25)) |
| 21 | +>FirstInterface : Symbol(FirstInterface, Decl(intersectionSatisfiesConstraint.ts, 0, 0)) |
| 22 | +>SecondInterface : Symbol(SecondInterface, Decl(intersectionSatisfiesConstraint.ts, 2, 1)) |
| 23 | +>param1 : Symbol(param1, Decl(intersectionSatisfiesConstraint.ts, 8, 69)) |
| 24 | +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 8, 25)) |
| 25 | + |
| 26 | + const newParam: T & { otherProperty: number } = Object.assign(param1, { otherProperty: 3 }) |
| 27 | +>newParam : Symbol(newParam, Decl(intersectionSatisfiesConstraint.ts, 9, 9)) |
| 28 | +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 8, 25)) |
| 29 | +>otherProperty : Symbol(otherProperty, Decl(intersectionSatisfiesConstraint.ts, 9, 25)) |
| 30 | +>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, --, --)) |
| 31 | +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) |
| 32 | +>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, --, --)) |
| 33 | +>param1 : Symbol(param1, Decl(intersectionSatisfiesConstraint.ts, 8, 69)) |
| 34 | +>otherProperty : Symbol(otherProperty, Decl(intersectionSatisfiesConstraint.ts, 9, 75)) |
| 35 | + |
| 36 | + mySecondFunction(newParam) |
| 37 | +>mySecondFunction : Symbol(mySecondFunction, Decl(intersectionSatisfiesConstraint.ts, 13, 5)) |
| 38 | +>newParam : Symbol(newParam, Decl(intersectionSatisfiesConstraint.ts, 9, 9)) |
| 39 | +} |
| 40 | + |
| 41 | +const mySecondFunction = <T extends { commonProperty: number, otherProperty: number }>(newParam: T) => { |
| 42 | +>mySecondFunction : Symbol(mySecondFunction, Decl(intersectionSatisfiesConstraint.ts, 13, 5)) |
| 43 | +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 13, 26)) |
| 44 | +>commonProperty : Symbol(commonProperty, Decl(intersectionSatisfiesConstraint.ts, 13, 37)) |
| 45 | +>otherProperty : Symbol(otherProperty, Decl(intersectionSatisfiesConstraint.ts, 13, 61)) |
| 46 | +>newParam : Symbol(newParam, Decl(intersectionSatisfiesConstraint.ts, 13, 87)) |
| 47 | +>T : Symbol(T, Decl(intersectionSatisfiesConstraint.ts, 13, 26)) |
| 48 | + |
| 49 | + return newParam |
| 50 | +>newParam : Symbol(newParam, Decl(intersectionSatisfiesConstraint.ts, 13, 87)) |
| 51 | +} |
| 52 | + |
0 commit comments