forked from prettier/prettier
-
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.
Support TS 4.7 optional variance (prettier#12900)
* Print `in` and `out` * Add tests * Add tests for jsx
- Loading branch information
1 parent
52e86de
commit 5466e8a
Showing
4 changed files
with
407 additions
and
0 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
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
64 changes: 64 additions & 0 deletions
64
tests/format/misc/typescript-babel-only/ts-4.7-optional-variance-with-jsx.tsx
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,64 @@ | ||
// valid JSX | ||
<in T>() => {}</in>; | ||
|
||
type Covariant<out T> = { | ||
x: T; | ||
} | ||
type Contravariant<in T> = { | ||
f: (x: T) => void; | ||
} | ||
type Invariant<in out T> = { | ||
f: (x: T) => T; | ||
} | ||
type T10<out T> = T; | ||
type T11<in T> = keyof T; | ||
type T12<out T, out K extends keyof T> = T[K]; | ||
type T13<in out T> = T[keyof T]; | ||
|
||
type Covariant1<in T> = { | ||
x: T; | ||
} | ||
|
||
type Contravariant1<out T> = keyof T; | ||
|
||
type Contravariant2<out T> = { | ||
f: (x: T) => void; | ||
} | ||
|
||
type Invariant1<in T> = { | ||
f: (x: T) => T; | ||
} | ||
|
||
type Invariant2<out T> = { | ||
f: (x: T) => T; | ||
} | ||
type Foo1<in T> = { | ||
x: T; | ||
f: FooFn1<T>; | ||
} | ||
|
||
type Foo2<out T> = { | ||
x: T; | ||
f: FooFn2<T>; | ||
} | ||
|
||
type Foo3<in out T> = { | ||
x: T; | ||
f: FooFn3<T>; | ||
} | ||
|
||
type T21<in out T> = T; | ||
|
||
interface Baz<out T> {} | ||
interface Baz<in T> {} | ||
|
||
interface Parent<out A> { | ||
child: Child<A> | null; | ||
parent: Parent<A> | null; | ||
} | ||
|
||
declare class StateNode<TContext, in out TEvent extends { type: string }> { | ||
_storedEvent: TEvent; | ||
_action: ActionObject<TEvent>; | ||
_state: StateNode<TContext, any>; | ||
} |
Oops, something went wrong.