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

TS6307 caused by ts files in excluded directory #27069

Closed
jamesamcl opened this issue Sep 13, 2018 · 15 comments
Closed

TS6307 caused by ts files in excluded directory #27069

jamesamcl opened this issue Sep 13, 2018 · 15 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@jamesamcl
Copy link

TypeScript Version: 3.1.0-dev.20180913

Search Terms: TS6307

Code

For example:

  • Have a dependency in node_modules which contains .ts files.
  • Exclude node_modules in tsconfig.json
  • Build with tsc -b -v.

Expected behavior:

As node_modules is excluded, the files should be ignored.

Actual behavior:

error TS6307: File '/foo/bar/node_modules/somemodule/something.ts' is not in project file list. Projects must list all files or use an 'include' pattern.

Playground Link:

Related Issues:

@jamesamcl
Copy link
Author

I tried making an include list and explicitly including my source files:

"include": [
   "src/**/*"
]

This results in error TS6307 for both the files in node_modules and the files I explicitly included from src.

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Sep 21, 2018
@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Sep 21, 2018

Can you make a sample repo or zip file? Lots of variables in play here and we'd like to jump straight to the problem.

@blink1073
Copy link

I am seeing similar behavior in a monorepo that uses composite. I think it is a result of nested folders in the reference src. Repro:

git clone https://github.com/blink1073/jupyterlab --branch just-cont
cd jupyterlab/tests/test-services
yarn
yarn build
build output
$ yarn build
yarn run v1.9.4
$ tsc -b src
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/builder/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/config/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/contents/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/contents/validate.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/kernel/comm.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/kernel/default.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/kernel/future.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/kernel/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/kernel/kernel.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/kernel/manager.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/kernel/messages.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/kernel/serialize.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/kernel/validate.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/manager.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/nbconvert/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/serverconnection.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/session/default.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/session/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/session/manager.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/session/session.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/session/validate.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/setting/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/terminal/default.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/terminal/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/terminal/manager.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/terminal/terminal.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error TS6307: File 'c:/users/steve/temp/jupyterlab/packages/services/src/workspace/index.ts' is not in project file list. Projects must list all files or use an 'include' pattern.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@blink1073
Copy link

False alarm @RyanCavanaugh , we were missing the references config in our test- folders.

@jamesamcl
Copy link
Author

@RyanCavanaugh Can't reproduce with TypeScript 3.1.1. Think this must have been fixed.

@chris-miaskowski
Copy link

@udp this is an actual bug. I would reopen this.

I found the exact line that is causing the issue: https://github.com/Microsoft/TypeScript/blob/7ed9e44055d31949f2b633284f7bf8eed4abff96/src/compiler/program.ts#L2587

For some reason if options.composite is true they check if processed files can be found on the path (they don't do that otherwise).

If the module you depend on exports pure .ts files this will fail.

I found a workaround for this: convert .ts to .d.ts... but I would rather see that fixed at some point.

@jamesamcl
Copy link
Author

@chris-miaskowski Thanks. Dutifully reopening.

@sheetalkamat
Copy link
Member

Can you please provide repro so we can look into what best we can do?

@unional
Copy link
Contributor

unional commented Oct 28, 2018

Might be the same issue as in: #25600 (comment)

@unional
Copy link
Contributor

unional commented Oct 28, 2018

Repro here: https://github.com/unional/learn-a/tree/issue-27069

Run tsc -b or tsc -b --force under packages/pkg1

@sheetalkamat
Copy link
Member

sheetalkamat commented Oct 30, 2018

@unional this seems to work fine with drop from master.

c:\temp\learn-a\packages\pkg1>node c:\TypeScript\built\local\tsc.js -b --v --listFiles -f
[07:03:50] Projects in this build:
    * tsconfig.json

[07:03:50] Project 'tsconfig.json' is up to date because newest input 'src/index.ts' is older than oldest output 'lib/foo.js.map'

[07:03:50] Building project 'c:/temp/learn-a/packages/pkg1/tsconfig.json'...

c:/TypeScript/built/local/lib.d.ts
c:/TypeScript/built/local/lib.es5.d.ts
c:/TypeScript/built/local/lib.dom.d.ts
c:/TypeScript/built/local/lib.webworker.importscripts.d.ts
c:/TypeScript/built/local/lib.scripthost.d.ts
c:/temp/learn-a/packages/pkg1/src/foo.ts
c:/temp/learn-a/packages/pkg1/src/index.ts

Same result also with 3.1.3

@sheetalkamat
Copy link
Member

Ignore earlier comment (where i forgot to checkout the branch). The repro is working as intended since src/foo.ts is included by the tsconfig and isnt listed in files/include array as mentioned in the error.

c:\temp\learn-a\packages\pkg1>type tsconfig.json
{
  "extends": "../tsconfig.settings.json",
  "compilerOptions": {
    "outDir": "lib",
    "rootDir": "src"
  },
  "files": [
    "src/index.ts"
  ]
}

c:\temp\learn-a\packages\pkg1>node node_modules\typescript\lib\tsc.js --b --v --f --listFiles
[07:07:39] Projects in this build:
    * tsconfig.json

[07:07:39] Project 'tsconfig.json' is up to date because newest input 'src/index.ts' is older than oldest output 'lib/index.js.map'

[07:07:39] Building project 'c:/temp/learn-a/packages/pkg1/tsconfig.json'...

error TS6307: File 'c:/temp/learn-a/packages/pkg1/src/foo.ts' is not in project file list. Projects must list all files or use an 'include' pattern.


c:\temp\learn-a\packages\pkg1>type src\index.ts
export * from "./foo";

@sheetalkamat sheetalkamat added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Needs More Info The issue still hasn't been fully clarified labels Oct 30, 2018
@silentorb
Copy link

silentorb commented May 10, 2019

So, a bug is presented, @unional provides a repo that doesn't reproduce the bug, and the issue is closed as "Working as Intended"?

I've created a repo that reproduces the bug: https://github.com/silentorb/typescript-project-test.

A project I'm working on is currently running into this issue. We're trying to modify a yarn workspace to use TypeScript project references and are running into the same symptoms described by the OP when importing a third party TypeScript library I maintain: https://github.com/vineyard-bloom/vineyard-lawn.

As an example, when building with tsc we get the following error:

error TS6307: File 'node_modules\vineyard-lawn\src\api.ts' is not in project file list. Projects must list all files or use an 'include' pattern.

The directory node_modules\vineyard-lawn\src contains both an api.ts file and an api.d.ts file. When I delete the api.ts file the above error goes away.

If the design of TypeScript project references is to not support third party libraries with .ts files, then that should be specified in the documentation: https://www.typescriptlang.org/docs/handbook/project-references.html#caveats-for-project-references.

Note that the errors appear with or without the -b flag. The critical factors are having a project with composite set to true and code that imports excluded .d.ts files with neighboring .ts files.

@sheetalkamat
Copy link
Member

@silentorb I ran the build using typescript@next on https://github.com/silentorb/typescript-project-test and it runs without any errors and i think your issue should be fixed by #31191

c:\temp\typescript-project-test>node node_modules\typescript\lib\tsc.js  -v
Version 3.5.0-dev.20190514

c:\temp\typescript-project-test>node node_modules\typescript\lib\tsc.js

c:\temp\typescript-project-test>

@razzeee
Copy link

razzeee commented Jun 3, 2019

I'm getting this with https://github.com/elm-tooling/elm-language-server/tree/d5887bfce2d39f5683b6b94cd612047a1a132c75 (be sure to init the git submodule) and typescript 3.5.1 on linux.

Screenshot from 2019-06-04 00-34-10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

8 participants