sergiodxa/remix-utils

remix-utils: missing type declarations (regression)

rolanday opened this issue · 9 comments

Describe the bug

Latest version of remix-util is broke for me (cannot import from). A clean remix-install results in following when attempting to import:

app/routes/_index.tsx:1:36 - error TS2307: Cannot find module 'remix-utils' or its corresponding type declarations.

1 import { getClientIPAddress } from "remix-utils";
                                     ~~~~~~~~~~~~~


Found 1 error in app/routes/_index.tsx:1

Repro avail here: https://github.com/rolanday/repro-remix-util

Same result using bun and npm package managers

Your Example Website or App

https://github.com/rolanday/repro-remix-util

Steps to Reproduce the Bug or Issue

  1. Create new remix project (typescript)
  2. npm i remix-utils
  3. Try to import remix-utils
  4. Note cannot find module error

Expected behavior

To be able to import from remix-utils

Screenshots or Videos

No response

Platform

  • OS: macOS (Sonoma v14.0)
  • Browser: N/A

Additional context

No response

This is mentioned on the Upgrade from Remix Utils v6 section of the README, specifically on the Updated Import Paths section

Thank you. My bad for not checking most obvious place (readme) for solution.

Screenshot 2023-10-10 at 0 04 16 PM

@sergiodxa

I updated my import paths and I'm still getting the error. (The JS works though.)

@brandonpittman did you added "moduleResolution": "Bundler" to tsconfig.json?

Screenshot 2023-10-11 at 10 28 48 AM

@sergiodxa

Yes, and I'm on the latest TypeScript, but tsserver doesn't like that value. I haven't upgraded to Remix v2 yet—not sure if that matters.

If TS doesn't allow moduleResolution to be Bundler then you're not on TS v5.

And latest Remix Utils version needs Remix v2, if you're still in v1 it's better to stick with Remix Utils v6.

@sergiodxa Sorry. It wound up being a problem with my editor extension for tsserver being too older to work with TSv5 and the bundler setting. 🙇🏻

@sergiodxa I am trying to upgrade a project to Remix v2 and remix-utils to v7 as well. Also facing TS error. We are on

"module": "CommonJS",
"moduleResolution": "node"

and I am hesitant to make this an even bigger change (had to upgrade pretty much every dependency as well as Node). Is there a way around this issue?

@lananelson you need to change your tsconfig module resolution to Bundler.