-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce at more stages, add test from related issue
- Loading branch information
Showing
6 changed files
with
736 additions
and
30 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
94 changes: 94 additions & 0 deletions
94
tests/baselines/reference/simplifyingExpressionTypeNotTooComplexToRepresent.errors.txt
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,94 @@ | ||
tests/cases/compiler/simplifyingExpressionTypeNotTooComplexToRepresent.ts(6,22): error TS2345: Argument of type 'Family | Size | Keyword<"percentage"> | Keyword<"ultra-condensed"> | Keyword<"extra-condensed"> | Keyword<"condensed"> | Keyword<"semi-condensed"> | Keyword<"normal"> | Keyword<"semi-expanded"> | Keyword<"expanded"> | Keyword<"extra-expanded"> | Keyword<"ultra-expanded"> | Caps | Keyword<"jis78"> | Keyword<"jis83"> | Keyword<"jis90"> | Keyword<"jis04"> | Keyword<"simplified"> | Keyword<"traditional"> | Keyword<"proportional-width"> | Keyword<"full-width"> | Keyword<"ruby"> | Keyword<"none"> | Keyword<"common-ligatures"> | Keyword<"no-common-ligatures"> | Keyword<"discretionary-ligatures"> | Keyword<"no-discretionary-ligatures"> | Keyword<"historical-ligatures"> | Keyword<"no-historical-ligatures"> | Keyword<"contextual"> | Keyword<"no-contextual"> | Keyword<"lining-nums"> | Keyword<"oldstyle-nums"> | Keyword<"proportional-nums"> | Keyword<"tabular-nums"> | Keyword<"diagonal-fractions"> | Keyword<"stacked-fractions"> | Keyword<"ordinal"> | Keyword<"slashed-zero"> | Keyword<"sub"> | Keyword<"super"> | Keyword<"number"> | Keyword<"bold"> | Keyword<"bolder"> | Keyword<"lighter">' is not assignable to parameter of type 'never'. | ||
Type 'Family' is not assignable to type 'never'. | ||
|
||
|
||
==== tests/cases/compiler/simplifyingExpressionTypeNotTooComplexToRepresent.ts (1 errors) ==== | ||
function computed<N extends keyof Longhands>( | ||
property: Longhands[N][1], | ||
specified: Longhands[N][0] | ||
) { | ||
// error happens on this line | ||
property.compute(specified); | ||
~~~~~~~~~ | ||
!!! error TS2345: Argument of type 'Family | Size | Keyword<"percentage"> | Keyword<"ultra-condensed"> | Keyword<"extra-condensed"> | Keyword<"condensed"> | Keyword<"semi-condensed"> | Keyword<"normal"> | Keyword<"semi-expanded"> | Keyword<"expanded"> | Keyword<"extra-expanded"> | Keyword<"ultra-expanded"> | Caps | Keyword<"jis78"> | Keyword<"jis83"> | Keyword<"jis90"> | Keyword<"jis04"> | Keyword<"simplified"> | Keyword<"traditional"> | Keyword<"proportional-width"> | Keyword<"full-width"> | Keyword<"ruby"> | Keyword<"none"> | Keyword<"common-ligatures"> | Keyword<"no-common-ligatures"> | Keyword<"discretionary-ligatures"> | Keyword<"no-discretionary-ligatures"> | Keyword<"historical-ligatures"> | Keyword<"no-historical-ligatures"> | Keyword<"contextual"> | Keyword<"no-contextual"> | Keyword<"lining-nums"> | Keyword<"oldstyle-nums"> | Keyword<"proportional-nums"> | Keyword<"tabular-nums"> | Keyword<"diagonal-fractions"> | Keyword<"stacked-fractions"> | Keyword<"ordinal"> | Keyword<"slashed-zero"> | Keyword<"sub"> | Keyword<"super"> | Keyword<"number"> | Keyword<"bold"> | Keyword<"bolder"> | Keyword<"lighter">' is not assignable to parameter of type 'never'. | ||
!!! error TS2345: Type 'Family' is not assignable to type 'never'. | ||
} | ||
|
||
interface Property<T> { | ||
compute: (value: T) => T; | ||
} | ||
|
||
type Wrapper<T> = [T, Property<T>]; | ||
|
||
interface Longhands { | ||
"font-family": Wrapper<Family>; | ||
"font-size": Wrapper<Size>; | ||
"font-stretch": Wrapper<Stretch>; | ||
"font-variant-caps": Wrapper<Caps>; | ||
"font-variant-east-asian": Wrapper<EastAsian>; | ||
"font-variant-ligatures": Wrapper<Ligatures>; | ||
"font-variant-numeric": Wrapper<Numeric>; | ||
"font-variant-position": Wrapper<Position>; | ||
"font-weight": Wrapper<Weight>; | ||
} | ||
|
||
class Keyword<K extends string> { | ||
keyword: K; | ||
constructor(keyword: K) { | ||
this.keyword = keyword; | ||
} | ||
} | ||
|
||
type Family = Keyword<"serif">; | ||
type Size = Keyword<"length">; | ||
type Stretch = | ||
| Keyword<"percentage"> | ||
| Keyword<"ultra-condensed"> | ||
| Keyword<"extra-condensed"> | ||
| Keyword<"condensed"> | ||
| Keyword<"semi-condensed"> | ||
| Keyword<"normal"> | ||
| Keyword<"semi-expanded"> | ||
| Keyword<"expanded"> | ||
| Keyword<"extra-expanded"> | ||
| Keyword<"ultra-expanded">; | ||
type Caps = Keyword<"normal">; | ||
type EastAsian = | ||
| Keyword<"normal"> | ||
| Keyword<"jis78"> | ||
| Keyword<"jis83"> | ||
| Keyword<"jis90"> | ||
| Keyword<"jis04"> | ||
| Keyword<"simplified"> | ||
| Keyword<"traditional"> | ||
| Keyword<"proportional-width"> | ||
| Keyword<"full-width"> | ||
| Keyword<"ruby">; | ||
type Ligatures = | ||
| Keyword<"none"> | ||
| Keyword<"normal"> | ||
| Keyword<"common-ligatures"> | ||
| Keyword<"no-common-ligatures"> | ||
| Keyword<"discretionary-ligatures"> | ||
| Keyword<"no-discretionary-ligatures"> | ||
| Keyword<"historical-ligatures"> | ||
| Keyword<"no-historical-ligatures"> | ||
| Keyword<"contextual"> | ||
| Keyword<"no-contextual">; | ||
type Numeric = | ||
| Keyword<"normal"> | ||
| Keyword<"lining-nums"> | ||
| Keyword<"oldstyle-nums"> | ||
| Keyword<"proportional-nums"> | ||
| Keyword<"tabular-nums"> | ||
| Keyword<"diagonal-fractions"> | ||
| Keyword<"stacked-fractions"> | ||
| Keyword<"ordinal"> | ||
| Keyword<"slashed-zero">; | ||
type Position = Keyword<"normal"> | Keyword<"sub"> | Keyword<"super">; | ||
type Weight = | ||
| Keyword<"number"> | ||
| Keyword<"normal"> | ||
| Keyword<"bold"> | ||
| Keyword<"bolder"> | ||
| Keyword<"lighter">; |
99 changes: 99 additions & 0 deletions
99
tests/baselines/reference/simplifyingExpressionTypeNotTooComplexToRepresent.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,99 @@ | ||
//// [simplifyingExpressionTypeNotTooComplexToRepresent.ts] | ||
function computed<N extends keyof Longhands>( | ||
property: Longhands[N][1], | ||
specified: Longhands[N][0] | ||
) { | ||
// error happens on this line | ||
property.compute(specified); | ||
} | ||
|
||
interface Property<T> { | ||
compute: (value: T) => T; | ||
} | ||
|
||
type Wrapper<T> = [T, Property<T>]; | ||
|
||
interface Longhands { | ||
"font-family": Wrapper<Family>; | ||
"font-size": Wrapper<Size>; | ||
"font-stretch": Wrapper<Stretch>; | ||
"font-variant-caps": Wrapper<Caps>; | ||
"font-variant-east-asian": Wrapper<EastAsian>; | ||
"font-variant-ligatures": Wrapper<Ligatures>; | ||
"font-variant-numeric": Wrapper<Numeric>; | ||
"font-variant-position": Wrapper<Position>; | ||
"font-weight": Wrapper<Weight>; | ||
} | ||
|
||
class Keyword<K extends string> { | ||
keyword: K; | ||
constructor(keyword: K) { | ||
this.keyword = keyword; | ||
} | ||
} | ||
|
||
type Family = Keyword<"serif">; | ||
type Size = Keyword<"length">; | ||
type Stretch = | ||
| Keyword<"percentage"> | ||
| Keyword<"ultra-condensed"> | ||
| Keyword<"extra-condensed"> | ||
| Keyword<"condensed"> | ||
| Keyword<"semi-condensed"> | ||
| Keyword<"normal"> | ||
| Keyword<"semi-expanded"> | ||
| Keyword<"expanded"> | ||
| Keyword<"extra-expanded"> | ||
| Keyword<"ultra-expanded">; | ||
type Caps = Keyword<"normal">; | ||
type EastAsian = | ||
| Keyword<"normal"> | ||
| Keyword<"jis78"> | ||
| Keyword<"jis83"> | ||
| Keyword<"jis90"> | ||
| Keyword<"jis04"> | ||
| Keyword<"simplified"> | ||
| Keyword<"traditional"> | ||
| Keyword<"proportional-width"> | ||
| Keyword<"full-width"> | ||
| Keyword<"ruby">; | ||
type Ligatures = | ||
| Keyword<"none"> | ||
| Keyword<"normal"> | ||
| Keyword<"common-ligatures"> | ||
| Keyword<"no-common-ligatures"> | ||
| Keyword<"discretionary-ligatures"> | ||
| Keyword<"no-discretionary-ligatures"> | ||
| Keyword<"historical-ligatures"> | ||
| Keyword<"no-historical-ligatures"> | ||
| Keyword<"contextual"> | ||
| Keyword<"no-contextual">; | ||
type Numeric = | ||
| Keyword<"normal"> | ||
| Keyword<"lining-nums"> | ||
| Keyword<"oldstyle-nums"> | ||
| Keyword<"proportional-nums"> | ||
| Keyword<"tabular-nums"> | ||
| Keyword<"diagonal-fractions"> | ||
| Keyword<"stacked-fractions"> | ||
| Keyword<"ordinal"> | ||
| Keyword<"slashed-zero">; | ||
type Position = Keyword<"normal"> | Keyword<"sub"> | Keyword<"super">; | ||
type Weight = | ||
| Keyword<"number"> | ||
| Keyword<"normal"> | ||
| Keyword<"bold"> | ||
| Keyword<"bolder"> | ||
| Keyword<"lighter">; | ||
|
||
//// [simplifyingExpressionTypeNotTooComplexToRepresent.js] | ||
function computed(property, specified) { | ||
// error happens on this line | ||
property.compute(specified); | ||
} | ||
var Keyword = /** @class */ (function () { | ||
function Keyword(keyword) { | ||
this.keyword = keyword; | ||
} | ||
return Keyword; | ||
}()); |
Oops, something went wrong.