forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize type references before relating them (microsoft#35266)
* Normalize type references before relating them in isRelatedTo * Add comments * Accept new baselines * Add regression tests * Accept new baselines * Use aliases when available in error reporting * Accept new baselines
- Loading branch information
1 parent
369900b
commit 58a05f3
Showing
5 changed files
with
191 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/unwitnessedTypeParameterVariance.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//// [unwitnessedTypeParameterVariance.ts] | ||
// Repros from #33872 | ||
|
||
export interface CalcObj<O> { | ||
read: (origin: O) => CalcValue<O>; | ||
} | ||
|
||
export type CalcValue<O> = CalcObj<O>; | ||
|
||
function foo<O>() { | ||
const unk: CalcObj<unknown> = { read: (origin: unknown) => unk } | ||
const x: CalcObj<O> = unk; | ||
} | ||
|
||
type A<T> = B<T>; | ||
|
||
interface B<T> { | ||
prop: A<T>; | ||
} | ||
|
||
declare let a: A<number>; | ||
declare let b: A<3>; | ||
|
||
b = a; | ||
|
||
|
||
//// [unwitnessedTypeParameterVariance.js] | ||
"use strict"; | ||
// Repros from #33872 | ||
exports.__esModule = true; | ||
function foo() { | ||
var unk = { read: function (origin) { return unk; } }; | ||
var x = unk; | ||
} | ||
b = a; |
67 changes: 67 additions & 0 deletions
67
tests/baselines/reference/unwitnessedTypeParameterVariance.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
=== tests/cases/compiler/unwitnessedTypeParameterVariance.ts === | ||
// Repros from #33872 | ||
|
||
export interface CalcObj<O> { | ||
>CalcObj : Symbol(CalcObj, Decl(unwitnessedTypeParameterVariance.ts, 0, 0)) | ||
>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 2, 25)) | ||
|
||
read: (origin: O) => CalcValue<O>; | ||
>read : Symbol(CalcObj.read, Decl(unwitnessedTypeParameterVariance.ts, 2, 29)) | ||
>origin : Symbol(origin, Decl(unwitnessedTypeParameterVariance.ts, 3, 11)) | ||
>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 2, 25)) | ||
>CalcValue : Symbol(CalcValue, Decl(unwitnessedTypeParameterVariance.ts, 4, 1)) | ||
>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 2, 25)) | ||
} | ||
|
||
export type CalcValue<O> = CalcObj<O>; | ||
>CalcValue : Symbol(CalcValue, Decl(unwitnessedTypeParameterVariance.ts, 4, 1)) | ||
>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 6, 22)) | ||
>CalcObj : Symbol(CalcObj, Decl(unwitnessedTypeParameterVariance.ts, 0, 0)) | ||
>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 6, 22)) | ||
|
||
function foo<O>() { | ||
>foo : Symbol(foo, Decl(unwitnessedTypeParameterVariance.ts, 6, 38)) | ||
>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 8, 13)) | ||
|
||
const unk: CalcObj<unknown> = { read: (origin: unknown) => unk } | ||
>unk : Symbol(unk, Decl(unwitnessedTypeParameterVariance.ts, 9, 9)) | ||
>CalcObj : Symbol(CalcObj, Decl(unwitnessedTypeParameterVariance.ts, 0, 0)) | ||
>read : Symbol(read, Decl(unwitnessedTypeParameterVariance.ts, 9, 35)) | ||
>origin : Symbol(origin, Decl(unwitnessedTypeParameterVariance.ts, 9, 43)) | ||
>unk : Symbol(unk, Decl(unwitnessedTypeParameterVariance.ts, 9, 9)) | ||
|
||
const x: CalcObj<O> = unk; | ||
>x : Symbol(x, Decl(unwitnessedTypeParameterVariance.ts, 10, 9)) | ||
>CalcObj : Symbol(CalcObj, Decl(unwitnessedTypeParameterVariance.ts, 0, 0)) | ||
>O : Symbol(O, Decl(unwitnessedTypeParameterVariance.ts, 8, 13)) | ||
>unk : Symbol(unk, Decl(unwitnessedTypeParameterVariance.ts, 9, 9)) | ||
} | ||
|
||
type A<T> = B<T>; | ||
>A : Symbol(A, Decl(unwitnessedTypeParameterVariance.ts, 11, 1)) | ||
>T : Symbol(T, Decl(unwitnessedTypeParameterVariance.ts, 13, 7)) | ||
>B : Symbol(B, Decl(unwitnessedTypeParameterVariance.ts, 13, 17)) | ||
>T : Symbol(T, Decl(unwitnessedTypeParameterVariance.ts, 13, 7)) | ||
|
||
interface B<T> { | ||
>B : Symbol(B, Decl(unwitnessedTypeParameterVariance.ts, 13, 17)) | ||
>T : Symbol(T, Decl(unwitnessedTypeParameterVariance.ts, 15, 12)) | ||
|
||
prop: A<T>; | ||
>prop : Symbol(B.prop, Decl(unwitnessedTypeParameterVariance.ts, 15, 16)) | ||
>A : Symbol(A, Decl(unwitnessedTypeParameterVariance.ts, 11, 1)) | ||
>T : Symbol(T, Decl(unwitnessedTypeParameterVariance.ts, 15, 12)) | ||
} | ||
|
||
declare let a: A<number>; | ||
>a : Symbol(a, Decl(unwitnessedTypeParameterVariance.ts, 19, 11)) | ||
>A : Symbol(A, Decl(unwitnessedTypeParameterVariance.ts, 11, 1)) | ||
|
||
declare let b: A<3>; | ||
>b : Symbol(b, Decl(unwitnessedTypeParameterVariance.ts, 20, 11)) | ||
>A : Symbol(A, Decl(unwitnessedTypeParameterVariance.ts, 11, 1)) | ||
|
||
b = a; | ||
>b : Symbol(b, Decl(unwitnessedTypeParameterVariance.ts, 20, 11)) | ||
>a : Symbol(a, Decl(unwitnessedTypeParameterVariance.ts, 19, 11)) | ||
|
47 changes: 47 additions & 0 deletions
47
tests/baselines/reference/unwitnessedTypeParameterVariance.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
=== tests/cases/compiler/unwitnessedTypeParameterVariance.ts === | ||
// Repros from #33872 | ||
|
||
export interface CalcObj<O> { | ||
read: (origin: O) => CalcValue<O>; | ||
>read : (origin: O) => CalcValue<O> | ||
>origin : O | ||
} | ||
|
||
export type CalcValue<O> = CalcObj<O>; | ||
>CalcValue : CalcValue<O> | ||
|
||
function foo<O>() { | ||
>foo : <O>() => void | ||
|
||
const unk: CalcObj<unknown> = { read: (origin: unknown) => unk } | ||
>unk : CalcObj<unknown> | ||
>{ read: (origin: unknown) => unk } : { read: (origin: unknown) => CalcObj<unknown>; } | ||
>read : (origin: unknown) => CalcObj<unknown> | ||
>(origin: unknown) => unk : (origin: unknown) => CalcObj<unknown> | ||
>origin : unknown | ||
>unk : CalcObj<unknown> | ||
|
||
const x: CalcObj<O> = unk; | ||
>x : CalcObj<O> | ||
>unk : CalcObj<unknown> | ||
} | ||
|
||
type A<T> = B<T>; | ||
>A : A<T> | ||
|
||
interface B<T> { | ||
prop: A<T>; | ||
>prop : A<T> | ||
} | ||
|
||
declare let a: A<number>; | ||
>a : A<number> | ||
|
||
declare let b: A<3>; | ||
>b : A<3> | ||
|
||
b = a; | ||
>b = a : A<number> | ||
>b : A<3> | ||
>a : A<number> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// @strict: true | ||
|
||
// Repros from #33872 | ||
|
||
export interface CalcObj<O> { | ||
read: (origin: O) => CalcValue<O>; | ||
} | ||
|
||
export type CalcValue<O> = CalcObj<O>; | ||
|
||
function foo<O>() { | ||
const unk: CalcObj<unknown> = { read: (origin: unknown) => unk } | ||
const x: CalcObj<O> = unk; | ||
} | ||
|
||
type A<T> = B<T>; | ||
|
||
interface B<T> { | ||
prop: A<T>; | ||
} | ||
|
||
declare let a: A<number>; | ||
declare let b: A<3>; | ||
|
||
b = a; |