microsoft / microsoft/TypeScript

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

Offen
#44,540 6 Kommentare 4 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@orta arbeitet bereits daran.

Seit 10.6.2021.

Bug Domain: tsc -b Rescheduled
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.