remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.

Home Page:https://remix.run

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeScript: useLoaderData is not working properly in 2.9

RafalFilipek opened this issue · comments

commented

Reproduction

https://stackblitz.com/edit/remix-run-remix-yartxj?file=app%2Froutes%2F_index.tsx

System Info

System:
  OS: Linux 5.0 undefined
  CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 0 Bytes / 0 Bytes
  Shell: 1.0 - /bin/jsh
Binaries:
  Node: 18.18.0 - /usr/local/bin/node
  Yarn: 1.22.19 - /usr/local/bin/yarn
  npm: 10.2.3 - /usr/local/bin/npm
  pnpm: 8.15.3 - /usr/local/bin/pnpm
npmPackages:
  @remix-run/dev: * => 2.9.0 
  @remix-run/node: * => 2.9.0 
  @remix-run/react: * => 2.9.0 
  @remix-run/serve: * => 2.9.0 
  vite: ^5.1.0 => 5.2.10

Used Package Manager

npm

Expected Behavior

Return value should be fully typed like in 2.8

Actual Behavior

For this simple installation, the returned value is typed as any.

I've also checked case with single fetch included in the include key in my tsconfig.json file. In this case, the returned value was unknown

commented

Have you tried downgrading? Because mine still not working even after downgrading.

Yep. Works on 2.8 just fine.

Have you tried downgrading? Because mine still not working even after downgrading.

Yep. Works on 2.8 just fine.

Sorry for not deleting comment in time. Yea, turns out it was my mistake.

Sorry about this folks! It looks like our TS build is accidentally picking up on the single-fetch.d.ts overrides and causing it to skip outputting some of the existing types because it thinks they're overridden all the time. We'll get a patch release out hopefully early tomorrow.

We just published 2.9.1-pre.0 with a fix if you want to confirm that resolves the issue

2.9.1-pre.0

2.9.1-pre.0 worked for me. Thanks @brophdawg11

Its still acting weird.
Thats what return;
image
But thats what I get;
image

We just published 2.9.1-pre.0 with a fix if you want to confirm that resolves the issue

Fixes the issue here!

@merthanmerter Could you provide a reproduction of your issue? defer is being inferred correctly for me (and others) on the prerelease.

Screenshot 2024-04-24 at 11 04 47 AM

This should be resolved in Remix 2.9.1. Please provide minimal reproductions if you're still seeing any type inference issues!

This should be resolved in Remix 2.9.1. Please provide minimal reproductions if you're still seeing any type inference issues!

Its working with 2.9.1.