Unable to compile project with the TypeScript compiler (tsc) v.5.1.6
Hey folks, apologies in advance in case I am missing something obvious.
I've noticed something very strange. the
tsc
compiler which I rarely use (but still need sometimes nevertheless) is unable to compile because of some OnConflictBuilder
error, which is way too cryptic for me to understand.
I made a bare-minimum reproducible demo here:
https://github.com/virtuallyunknown/kysely-tsc-error/
In VSCode while editing and viewing the code, all appears perfectly fine.GitHub
GitHub - virtuallyunknown/kysely-tsc-error
Contribute to virtuallyunknown/kysely-tsc-error development by creating an account on GitHub.
58 Replies
ok, it looks like this is a typescript issue.
downgrading from typescript
5.1.6
to 5.0.4
makes the error go away and it compiles without any errors.
looks like 5.1.3
also works, so something in 5.1.6
caused this issueHey π
That's very concerning, this might be also broken going forward in 5.2+
well you guys should probably report it to the TS team
recently 5.1.3 broke another lib (discord.js) but they fixed it with 5.1.6
anyway, just thought i'd let you know, if there is anything i can help with feel free to @me
is it still happening with 5.2 beta?
i haven't tried it, let me see
cause their issue template asks to check nightly, probably a good idea to check the upcoming one and its nightly
typescript@next is that the beta?
there is also typescript@beta
ok let me test
next probably newer
cause beta is out for a few days now
ok so
"typescript": "^5.2.0-beta"
asked me to change:
after I did it didn't work
will test @next nowdidn't work with same error?
yep
Untitled Diff - Diff Checker
[email protected] check tscsrc/countries.ts:7:27 - error TS2322: Type 'OnConflictUpdateBu
exactly the same
and unfortunately the same with
"typescript": "^5.2.0-dev.20230706"
which is npm i typescript@next
Do you want to open the issue @ typescript? I'm OK with opening it, but you should get credit for this
on the typescript github issues you mean?
yeah
i mean, i don't even understand what this error is, you'd be 100x times more qualified for the task
and no worries about credit, i mean i just accidentally discovered this, not much to be credited for here
but like you and igal are like the main devs, right? if the typescript team ask something you'd know what to tell
basically, a generic value was not unwrapped from
OnConflictTables<value>
to value
so it yells about a builder mismatch
need to dig into thisi see
its late over here haha, not as sharp atm
yeah, 3am here
same
let's open an issue for now @ kysely so people looking for issues see it
okay, are you asking me to do it or?
i can if you want
please π
all right
I'm finalizing some changes in JSON PR for another review pass
GitHub
Unable to compile project with the TypeScript compiler (tsc) v.5.1....
Originally I posted this on the Discord server. Since then we I also found out the issue is specific to TypeScript version 5.1.6. Basically the when you try to build with tsc, it will throw an erro...
Thanks! π«Άπ»
I'll try to investigate this tomorrow for the typescript issue, if @koskimas doesn't get to it first. It's a part of the codebase I haven't touched yet, but should still be quite familiar
no problem at all
I can't seem to reproduce this in typescript playground
it's only happening when compiling?
submitting a PR
have a feeling TypeScript had a bug, and we had a bug, and TypeScript never yelled at us for it. but in 5.1.6 they fixed it and started yelling.
i see you guys have figured it out and fixed it?
π
Yep, Igal fixed it.
amazing job guys
do you plan to release a version with this fix applied soon?
not that it's urgent for me, just curious
Solution
I just released 0.26.0 that has the fix in it
i am reading the patch notes as we speak haha
epic
thanks for the hard work you guys put into this π
Hey @koskimas sorry if this is a stupid question, but do you guys plan allowing
WhereExpressionFactory
to be used with whereRef
or filterWhereRef
in future releases, or that's something not possible/bad idea?
Right now you can build more complex queries with where
and filterWhere
, but the ones I mentioned above are just lhs
, op
, rhs
.There's no reason to have a callback version of
whereRef
or filterWhereRef
. What are you trying to do?well i posted a prediction league demo in #queries a week ago, and in there i thought it would've been helpful for type safety
let me try to come up with a super simple example
All
whereRef
does is handle the third argument as a reference. If you'd pass in a callback, there's no third argument anymore and the function is 100% equal to where(callback)
here for example I can chain two
filterWhereRef
which becomes AND
for example what if I wanted this to be an OR
yes, that's the obvious answer, but you lose 100% type safety this way
that's how i do it currently
You lose 0% of type safety that way... What do you mean?
i could be wrong then
Yes. All those methods are fully type-safe
Are you maybe confusing
eb.ref
to sql.ref
?no no, i probably just lack deep understanding
i thought there is a chance my question doesn't make sense π
yeah i know you can do that, but i read somewhere in your docs that
whereRef
was safer when you're using joins or something like that, could be misremembering
otherwise i do it like your demo in my project tooYou can try to change the columns, tables etc in the expression and you'll see errors
The normal where method treats the right hand side argument as a value by default. whereRef
treats it as a column reference. This method is expecially useful with joins and correlated subqueries.
I guess this is what confused me
I have mistakenly thought that if you use
where
+ ref(...)
it might be less safer than whereRef
but yeah, i've no reason to doubt what you're saying here
i think this makes more sense now, whereRef
is like a shorthand for conveinence, where
is for values and complex logic πthis is potentially a rotten piece of documentation that needs updating, if you happen to remember where you saw it, would be awesome!
whoops π
no no all good, i just misunderstood the docs