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

Error: error TS5055: Cannot write file '...' because it would overwrite input file. #1639

Closed
balupton opened this issue Jul 29, 2021 · 9 comments
Labels
bug Functionality does not match expectation no bug This is expected behavior

Comments

@balupton
Copy link

Search terms

> typechecker@7.17.0 our:meta:docs:typedoc
> rm -Rf ./docs && typedoc --exclude '**/+(*test*|node_modules)' --excludeExternals --out ./docs ./source

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/async.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/classes-compiled.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/classes.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/index.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/map-empty.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/map.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/weakmap-empty.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/weakmap.js' because it would overwrite input file.

Expected Behavior

those files to be ignored due to the --exclude pattern

Actual Behavior

didn't work

Steps to reproduce the bug

git clone https://github.com/bevry/typechecker.git
cd typechecker
npm install
npm run our:release:prepare

Environment

  • Typedoc version: 0.21.4
  • TypeScript version: 4.3.5
  • Node.js version: 16.5.0
  • OS: Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 x86_64 - m1 mac mini 11.5.1 (20G80)
@balupton balupton added the bug Functionality does not match expectation label Jul 29, 2021
@balupton
Copy link
Author

Solved by adding "exclude": ["test-fixtures", "node_modules", "source/test.ts"] to tsconfig, and // @ts-ignore to the fixture files

@balupton
Copy link
Author

actually, that causes my test file not to compile - so I don't know

@balupton balupton reopened this Jul 29, 2021
@balupton
Copy link
Author

Tried this too, but to no avail

{
  "compilerOptions": {
    "allowJs": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "maxNodeModuleJsDepth": 5,
    "moduleResolution": "Node",
    "strict": true,
    "target": "ES2019",
    "module": "ESNext"
  },
  "include": ["source"],
  "exclude": ["test-fixtures", "node_modules"],
  "typedocOptions": {
    "exclude": "**/+(*test*|node_modules)",
    "externalPattern": "test-fixtures/*",
    "excludeExternals": true,
    "excludeInternal": true,
    "excludeNotDocumented": true,
    "excludePrivate": true,
    "excludeProtected": true,
    "entryPoints": ["source/index.ts"],
    "out": "docs"
  }
}

giving up for now

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 31, 2021

TypeDoc's behavior matches the behavior of npx tsc, which is expected.

Running npx tsc --explainFiles shows that your include pattern of "source" means that "source/test.ts" is included in the program, which means that all the files in test-fixtures are also included. If you change the include pattern to only include source/index.ts, TypeScript (and therefore TypeDoc) won't look at your test-fixtures directory.

Alternatively, set a output directory with "outDir": "dist" in your tsconfig and TypeScript will no longer have this error since it won't be trying to write JS files into the same directory they were discovered from.

@Gerrit0 Gerrit0 added the no bug This is expected behavior label Jul 31, 2021
@balupton
Copy link
Author

balupton commented Jul 31, 2021

So as we have multiple out dirs for different targets I should just set outDir to "/tmp" for typedoc? Is there another way to tell typedoc's tsc not to write anything? As we write our typescript output in our compile steps, not our doc step.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 31, 2021

You could also put "noEmit": true in your tsconfig, which is maybe something typedoc should do unless --emit is specified...

@balupton
Copy link
Author

balupton commented Jul 31, 2021

typedoc should do unless --emit is specified...

that would be great, as this is already the implied behaviour of it:

 --emit                    If set, TypeDoc will emit the TypeScript compilation result

tsc only provides the --noEmit flag:

 --noEmit                                           Do not emit outputs.

Right now it seems with either configuration option I will negate myself:

  • if I add noEmit to my tsconfig.json file, typedoc will work, however tsc won't compile the js for the editions, as tsc has no --emit flag
  • if I don't have noEmit in my tsconfig.json, then typedoc won't work as it doesn't have a --noEmit flag, however tsc will be able to compile its js for the editions

Setting "outDir": "/tmp" in my tsconfig.json produced the same failure in typedoc.

{
  "compilerOptions": {
    "allowJs": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "maxNodeModuleJsDepth": 5,
    "moduleResolution": "Node",
    "strict": true,
    "target": "ES2019",
    "module": "ESNext"
  },
  "include": ["source"],
  "exclude": ["test-fixtures", "node_modules"],
  "outDir": "/tmp",
  "typedocOptions": {
    "exclude": "**/+(*test*|node_modules)",
    "externalPattern": "test-fixtures/*",
    "excludeExternals": true,
    "excludeInternal": true,
    "excludeNotDocumented": true,
    "excludePrivate": true,
    "excludeProtected": true,
    "entryPoints": ["source/index.ts"],
    "out": "docs"
  }
}
> typedoc --tsconfig tsconfig.json 
Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/async.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/classes-compiled.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/classes.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/index.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/map-empty.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/map.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/weakmap-empty.js' because it would overwrite input file.

Error: error TS5055: Cannot write file '/Users/balupton/Projects/auto-fixes/typechecker/test-fixtures/weakmap.js' because it would overwrite input file.

[3]:23:58:17:/Users/balupton/Projects/auto-fixe

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 31, 2021

You put outDir in the wrong place - it lives within compilerOptions.. I think I will make typedoc behave as if noEmit is set unless --emit is specified.

@balupton
Copy link
Author

I think I will make typedoc behave as if noEmit is set unless --emit is specified.

Great, this works (editions are compiled, documentation is compiled) as a workaround:

{
  "compilerOptions": {
    "outDir": "/tmp",
    "allowJs": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "maxNodeModuleJsDepth": 5,
    "moduleResolution": "Node",
    "strict": true,
    "target": "ES2019",
    "module": "ESNext"
  },
  "include": ["source"]
}

I think I will make typedoc behave as if noEmit is set unless --emit is specified.

That will be great, thank you.

balupton added a commit to bevry/boundation that referenced this issue Jul 31, 2021
balupton added a commit to bevry/typechecker that referenced this issue Jul 31, 2021
balupton added a commit to bevry/typechecker that referenced this issue Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation no bug This is expected behavior
Projects
None yet
Development

No branches or pull requests

2 participants