Skip to content

TypeScript "paths" in monorepo #620

Answered by mfpopa
steveruizok asked this question in Help
Jan 27, 2022 · 15 comments · 24 replies
Discussion options

You must be logged in to vote

To eliminate the build step, you need add the paths from ui/tsconfig.json in the tsconfig of docs and web projects like this:

{
  "extends": "tsconfig/nextjs.json",
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"],
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "~*": ["../../packages/ui/src/*"]
    }
  }
}

Next.js is smart enough to pick up the paths automatically from the tsconfig.json file, just remember to restart the Next.js server after each change made to tsconfig.json.

Also make sure you have the main and types properties in the ui package set to the index.tsx file since you no longer have the build step to create the index.js in…

Replies: 15 comments 24 replies

Comment options

You must be logged in to vote
9 replies
@maipato10
Comment options

@daabe3
Comment options

@bestickley
Comment options

@T04435
Comment options

@EfstathiadisD
Comment options

Answer selected by jaredpalmer
Comment options

You must be logged in to vote
4 replies
@lucaschultz
Comment options

@jwenger100
Comment options

@citypaul
Comment options

@mayvagio2016
Comment options

Comment options

You must be logged in to vote
1 reply
@jmroon
Comment options

Comment options

You must be logged in to vote
1 reply
@jmroon
Comment options

Comment options

You must be logged in to vote
2 replies
@lveillard
Comment options

@acnicolasdc
Comment options

Comment options

You must be logged in to vote
2 replies
@jmroon
Comment options

@airtonix
Comment options

Comment options

You must be logged in to vote
2 replies
@un33k
Comment options

@jmroon
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@andresgutgon
Comment options

@Nikola-Milovic
Comment options

@andresgutgon
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet