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

transpileOnly does not work with projectReferences #1158

Closed
chancancode opened this issue Jul 22, 2020 · 7 comments
Closed

transpileOnly does not work with projectReferences #1158

chancancode opened this issue Jul 22, 2020 · 7 comments
Labels

Comments

@chancancode
Copy link

chancancode commented Jul 22, 2020

Steps to Reproduce the Problem

Set up a project that uses transpileOnly: true and projectReferences: true. Something like this:

// root tsconfig.json
{
  "include": ["index.ts"],
  "compilerOptions": {
    "outDir": "dist",
    "references": [
      { "path": "./packages/sub-project" },
      // ...
    ]
  }
}
// packages/sub-project/tsconfig.json
{
  "compilerOptions": {
    "outDir": "dist",
    "composite": true,
    "declaration": true
  }
}

Expected Behaviour

When a type error is introduced in either the root project or the sub-project, the build should work and emit the JS files despite the type error.

Actual Behaviour

When a type error is introduced in either the root project, the build would work and the JS files are emitted. However, when a type error is introduced in the sub-project(s), the build fails and no JS files are emitted.

Location of a Minimal Repository that Demonstrates the Issue.

https://github.com/emberjs/ember-debug/tree/d8ae4c9019f1fd673532c56575dc35898335d958 can be used to test this (by enabling transpileOnly: true which is not included in the repo yet)

@appzuka
Copy link
Member

appzuka commented Jul 26, 2020

I believe this behaviour is expected. When you define a project reference, that sub-project is built in the same way as if you typed tsc --build in the sub-project's directory. If there are errors they will be reported. Files which were not part of the sub-project will be built by webpack calling ts-loader and if you include the transpileOnly option then the file will not be checked for type errors.

There is a need for documentation for project references as this is a relatively new feature. This behaviour could be part of the documentation.

@desmap
Copy link

desmap commented Aug 26, 2020

just to get the terminology right, I also just tested this, check #1173 (comment) and when...

CASE A: I have transpileOnly: true in ts-loader options + fork-ts-checker enabled

  1. ❌No type errors if the type error is in a non-reference file (eg. a file that imports a reference but doesn't get imported itself)
  2. ✔Type errors if the type error is in a reference file (eg. a file that gets imported)

CASE B: I just have fork-ts-checker enabled:

  1. ✔Type errors if the type error is in a non-reference file (eg. a file that imports a reference but doesn't get imported itself)
  2. ✔Type errors if the type error is in a reference file (eg. a file that gets imported)

So, IDK if this reflects the same issue of OP because he uses the term subproject. But I'd expected that reference files might have problems with type checking and not non-reference files.

CC @johnnyreilly

@desmap
Copy link

desmap commented Aug 26, 2020

just read OP's issue again and he has another problem (his build fails) and he doesn't use fork-ts-checker.

shall we still keep the discussion here for now (i closed that PR and that other multcompile issue might be also the wrong place)?

@desmap
Copy link

desmap commented Aug 26, 2020

fwiw fork-ts-checker's profiling output, is this normal that fork-ts-checker isn't doing anything? Both files have over 1,000 functions in an array each

CASE A1

Parse Configuration:                0.03 s
Create Watch Compiler Host:         0.00 s
I/O Read:                           0.00 s
Parse:                              0.00 s
Program:                            0.02 s
Semantic Diagnostics:               0.00 s
Create Watch Program:               0.03 s
Poll And Invoke Created Or Deleted: 0.00 s
Queued Tasks:                       0.00 s

CASE A2

Parse Configuration:                0.02 s
Create Watch Compiler Host:         0.00 s
I/O Read:                           0.00 s
Parse:                              0.00 s
Program:                            0.02 s
Semantic Diagnostics:               0.00 s
Create Watch Program:               0.03 s
Poll And Invoke Created Or Deleted: 0.00 s
Queued Tasks:                       0.00 s

CASE B1

Parse Configuration:                0.01 s
Create Watch Compiler Host:         0.00 s
I/O Read:                           0.00 s
Parse:                              0.00 s
Program:                            0.01 s
Semantic Diagnostics:               0.00 s
Create Watch Program:               0.02 s
Poll And Invoke Created Or Deleted: 0.00 s
Queued Tasks:                       0.00 s

CASE B2

Parse Configuration:                0.02 s
Create Watch Compiler Host:         0.00 s
I/O Read:                           0.00 s
Parse:                              0.00 s
Program:                            0.01 s
Semantic Diagnostics:               0.00 s
Create Watch Program:               0.02 s
Poll And Invoke Created Or Deleted: 0.00 s
Queued Tasks:                       0.00 s

@desmap
Copy link

desmap commented Aug 26, 2020

fyi I found the problem: I needed to set context explicitly to the to be compiled project folder within the project references structure (in this case client). now fork-ts shows also some activity

@stale
Copy link

stale bot commented Nov 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 1, 2020
@stale
Copy link

stale bot commented Nov 29, 2020

Closing as stale. Please reopen if you'd like to work on this further.

@stale stale bot closed this as completed Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants