TypeScript Version: 3.5.1
Search Terms:
parameter, never, return type inference
Code
typeNeverF=(arg : never)=>void;//"y"typeExtends=NeverFextends(...args : any)=>any ?
"y" :
"n";typeTsReturnType<Textends(...args : any)=>any>=Textends(...args : any)=> infer R ?
R :
"wtf";//Expected: void//Actual : "wtf"typer=TsReturnType<NeverF>;//Expected: void//Actual : anytyper2=ReturnType<NeverF>;
Expected behavior:
Both should resolve to void
Actual behavior:
Both resolve to the false branch
Playground Link:Playground
Related Issues:
Did a search for "parameter never in:title" and found nothing
I'm using a function with a parameter of type never because I only care about the return type. And I do not want the user to invoke the function explicitly.
Given the following,
constquery2=myQuery.map((row)=>{return{
...row,x : Math.random(),};});The type of query2 should now be something like,
{/*snip*/mapDelegate : (row : never,connection : /*snip*/)=>({/*snip typeof row*/,x : number}),/*snip*/}Then,
constquery3=query2.map((row)=>{return{
...row,x : row.x+3.141,y : "someNewValue",};});The type of query3 should now be something like,
{/*snip*/mapDelegate : (row : never,connection : /*snip*/)=>({/*snip typeof row*/,x : number,y : string}),/*snip*/}
I'm also using a never parameter because I want to save on Emit time. It sounds funny but literally every bit of text I shave off helps with compile times.
For large queries, the type of the row parameter could be huuuuuuggeeeee. Like, 100+ lines long.
So,
- Only care about the return type
- Not meant to be invoked externally
- Save on emit time
TypeScript Version: 3.5.1
Search Terms:
parameter, never, return type inference
Code
Expected behavior:
Both should resolve to
voidActual behavior:
Both resolve to the
falsebranchPlayground Link:Playground
Related Issues:
Did a search for "parameter never in:title" and found nothing
I'm using a function with a parameter of type
neverbecause I only care about the return type. And I do not want the user to invoke the function explicitly.Given the following,
The type of
query2should now be something like,Then,
The type of
query3should now be something like,I'm also using a
neverparameter because I want to save onEmit time. It sounds funny but literally every bit of text I shave off helps with compile times.For large queries, the type of the
rowparameter could be huuuuuuggeeeee. Like, 100+ lines long.So,