microsoft / microsoft/TypeScript

Project references: error when importing `tsx` file in referenced project

Open
#44,540 6 comments 4 reactions 1 assignee View on GitHub

@orta is already working on this.

Since Jun 10, 2021.

Bug Domain: tsc -b Rescheduled
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

project references jsx tsx typescriptreact javascriptreact compiler options composite

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about project references
⏯ Playground Link

N/A

💻 Code

Reduced test case: https://github.com/OliverJAsh/ts-project-references-jsx-bug

shared/tsconfig.json:

{
    "compilerOptions": {
        "composite": true,
        "jsx": "react",
    }
}

shared/foo-jsx.tsx:

export const foo = 1;

app/tsconfig.json:

{
  "compilerOptions": {
    "composite": true
  },
  "references": [
    {
      "path": "../shared/tsconfig.json"
    }
  ]
}

app/main.ts:

import * as fooJsx from "../shared/foo-jsx";

fooJsx;
  1. Run tsc --build app/tsconfig.json --verbose
🙁 Actual behavior
[18:36:23] Projects in this build:
    * shared/tsconfig.json
    * app/tsconfig.json

[18:36:23] Project 'shared/tsconfig.json' is out of date because output file 'shared/foo-jsx.js' does not exist

[18:36:23] Building project '/Users/oliverash/Development/ts-project-references-jsx-bug/shared/tsconfig.json'...

[18:36:24] Project 'app/tsconfig.json' is out of date because output file 'app/main.js' does not exist

[18:36:24] Building project '/Users/oliverash/Development/ts-project-references-jsx-bug/app/tsconfig.json'...

app/main.ts:1:25 - error TS6305: Output file '/Users/oliverash/Development/ts-project-references-jsx-bug/shared/foo-jsx.d.ts' has not been built from source file '/Users/oliverash/Development/ts-project-references-jsx-bug/shared/foo-jsx.tsx'.

1 import * as fooJsx from "../shared/foo-jsx";
                          ~~~~~~~~~~~~~~~~~~~


Found 1 error.
🙂 Expected behavior

No errors.


I am able to workaround the error by adding "jsx": "react" to app/tsconfig.json, but this feels redundant. The file I am importing is from a referenced project so I shouldn't need to set compiler options for this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.