Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/baselines/reference/intersectionSatisfiesConstraint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//// [tests/cases/compiler/intersectionSatisfiesConstraint.ts] ////

//// [intersectionSatisfiesConstraint.ts]
interface FirstInterface {
commonProperty: number
}

interface SecondInterface {
commonProperty: number
}

const myFirstFunction = <T extends FirstInterface | SecondInterface>(param1: T) => {
const newParam: T & { otherProperty: number } = Object.assign(param1, { otherProperty: 3 })
mySecondFunction(newParam)
}

const mySecondFunction = <T extends { commonProperty: number, otherProperty: number }>(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;
};
52 changes: 52 additions & 0 deletions tests/baselines/reference/intersectionSatisfiesConstraint.symbols
Original file line number Diff line number Diff line change
@@ -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 = <T extends FirstInterface | SecondInterface>(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 = <T extends { commonProperty: number, otherProperty: number }>(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))
}

47 changes: 47 additions & 0 deletions tests/baselines/reference/intersectionSatisfiesConstraint.types
Original file line number Diff line number Diff line change
@@ -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 = <T extends FirstInterface | SecondInterface>(param1: T) => {
>myFirstFunction : <T extends FirstInterface | SecondInterface>(param1: T) => void
><T extends FirstInterface | SecondInterface>(param1: T) => { const newParam: T & { otherProperty: number } = Object.assign(param1, { otherProperty: 3 }) mySecondFunction(newParam)} : <T extends FirstInterface | SecondInterface>(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 : { <T extends {}, U>(target: T, source: U): T & U; <T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V; <T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; }
>Object : ObjectConstructor
>assign : { <T extends {}, U>(target: T, source: U): T & U; <T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V; <T extends {}, U, V, W>(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 : <T extends { commonProperty: number; otherProperty: number; }>(newParam: T) => T
>newParam : (FirstInterface | SecondInterface) & { otherProperty: number; }
}

const mySecondFunction = <T extends { commonProperty: number, otherProperty: number }>(newParam: T) => {
>mySecondFunction : <T extends { commonProperty: number; otherProperty: number; }>(newParam: T) => T
><T extends { commonProperty: number, otherProperty: number }>(newParam: T) => { return newParam} : <T extends { commonProperty: number; otherProperty: number; }>(newParam: T) => T
>commonProperty : number
>otherProperty : number
>newParam : T

return newParam
>newParam : T
}

19 changes: 19 additions & 0 deletions tests/cases/compiler/intersectionSatisfiesConstraint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @strict: true
// @lib: esnext

interface FirstInterface {
commonProperty: number
}

interface SecondInterface {
commonProperty: number
}

const myFirstFunction = <T extends FirstInterface | SecondInterface>(param1: T) => {
const newParam: T & { otherProperty: number } = Object.assign(param1, { otherProperty: 3 })
mySecondFunction(newParam)
}

const mySecondFunction = <T extends { commonProperty: number, otherProperty: number }>(newParam: T) => {
return newParam
}