Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project references: TS server does not find correct project #56959

Closed
OliverJAsh opened this issue Jan 5, 2024 · 3 comments Β· Fixed by #57196 or #59688
Closed

Project references: TS server does not find correct project #56959

OliverJAsh opened this issue Jan 5, 2024 · 3 comments Β· Fixed by #57196 or #59688
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Jan 5, 2024

πŸ”Ž Search Terms

  • project references
  • tsconfig.json

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about project references.

⏯ Playground Link

No response

πŸ’» Code

Full reduced test case: https://github.com/OliverJAsh/ts-project-references-nested

Contents inlined below.

tsconfig.json:

{
  "compilerOptions": {
    "outDir": "./dist/"
  },
  "references": [
    { "path": "./demos/tsconfig.json" },
    { "path": "./app/tsconfig.json" }
  ]
}

app/tsconfig.json:

{
  "compilerOptions": {
    "composite": true,
    "outDir": "../app-dist/"
  },
  "include": ["**/*"],
  "exclude": ["**/*-demos.*"]
}

app/Component-demos.ts:

// This errors.
import * as helpers from 'demos/helpers';

export const demo = () => {
    helpers;
}

demos/tsconfig.json:

{
  "compilerOptions": {
    "composite": true,
    "rootDir": "../",
    "outDir": "../demos-dist/",
    "paths": {
      "demos/*": ["./*"]
    }
  },
  "include": [
    "**/*",
    "../app/**/*-demos.*"
  ],
  "references": [{ "path": "../app/tsconfig.json" }]
}

demos/helpers.ts:

export const foo = 1;

πŸ™ Actual behavior

When I run tsc --build --verbose tsconfig.json, there are no errors, but when I open my editor (VS Code) and open the file app/Component-demos.ts, I see errors:

image

πŸ™‚ Expected behavior

No errors inside my editor.

Additional information about the issue

When app/Component-demos.ts is opened, I believe TypeScript traverses parent file directories searching for a tsconfig.json file, and it stops at the first file it finds which in this case is app/tsconfig.json. This TS project does not include the file app/Component-demos.ts, so I believe TypeScript should continue traversing parent file directories to search for another tsconfig.json that does include the file. In this case, we want TypeScript to discover the root tsconfig.json.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jan 5, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.4.0 milestone Jan 5, 2024
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label May 9, 2024
@OliverJAsh
Copy link
Contributor Author

@sheetalkamat I can still reproduce this issue with TypeScript 5.5.3β€”I've pushed another commit to my reduced test case. Just to check, has this been released?

@sheetalkamat
Copy link
Member

This fix isn’t in 5.5 but will be in 5.6 .. you can try it out using nightly in the mean time

@sheetalkamat sheetalkamat reopened this Aug 15, 2024
@sheetalkamat
Copy link
Member

This will be included in later release after we can improve perf on looking up in referenced projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
5 participants