#Next automatically recognize types and functions without importing them.

1 messages · Page 1 of 1 (latest)

upbeat ridge
#

I'm running a Next 14.1 app, with app router. I just made a reducer and a context, along with some types, all in their separate files. The types are located at root/types/product.ts, the reducer at root/lib/reducers/cart.ts and the context provider at root/components. They all automatically recognize the types, and the cotext provider client component even recognizes the reducer passed into the useContext hook - without med importing anything.

How is this possible?

leaden spindleBOT
#

Hi @upbeat ridge. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain specific information about how Next.js automatically recognizes types and functions without importing them.

However, Next.js does provide a TypeScript-first development experience for building your React application, which might be related to the behavior you're experiencing. You can learn more about it here (https://nextjs.org/docs/app/building-your-application/configuring/typescript).

For a more detailed understanding, I would recommend checking the official Next.js documentation or reaching out to the Next.js community for more insights.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: