GoogleFeud / ts-runtime-checks

A typescript transformer that automatically generates validation code from your types.
https://googlefeud.github.io/ts-runtime-checks/
MIT License
312 stars 7 forks source link

[BUG] Incompatibility with TypeScript 5.5.3 #59

Closed FredTreg closed 3 months ago

FredTreg commented 3 months ago

Describe the bug When using TypeScript 5.5.3, compiling with ts-runtime-checks fails with the following error on my project:

TypeError: Cannot read properties of undefined (reading 'kind')
    at getCannotFindNameDiagnosticForName (evalmachine.<anonymous>:72549:25)
    at getResolvedSymbol (evalmachine.<anonymous>:72563:9)
    at checkIdentifier (evalmachine.<anonymous>:75260:20)
    at checkExpressionWorker (evalmachine.<anonymous>:83795:16)
    at checkExpression (evalmachine.<anonymous>:83749:32)
    at checkNonNullExpression (evalmachine.<anonymous>:77984:29)
    at checkPropertyAccessExpression (evalmachine.<anonymous>:78063:162)
    at checkExpressionWorker (evalmachine.<anonymous>:83829:16)
    at checkExpression (evalmachine.<anonymous>:83749:32)
    at checkExpressionCached (evalmachine.<anonymous>:83423:28)

This works correctly with TypeScript 5.4.5

I have not yet tried to isolate the problem in case the bug is obvious to the ts-runtime-checks contributor. If more investigation/isolation is needed, please let me know.

Additional context

GoogleFeud commented 3 months ago

I can replicate this using a custom check containing property access (for example, $self.length). I just got a fix and'll release the patch tomorrow, but just in case - It'd be nice if you could remove any uses of checks that access properties (so all length checks) from your codebase and try to compile to see if it works.

FredTreg commented 3 months ago

I confirm it is working on some basic chunks of code but I am using MinLen and MaxLen massively (which are using Check<$self.length...) and I can't isolate these easily. So fingers crossed for now, hoping that what you detected will solve the issue.