Skip to content

Allow empty files array when extending config. #26803

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

Closed
pgraham opened this issue Aug 31, 2018 · 2 comments
Closed

Allow empty files array when extending config. #26803

pgraham opened this issue Aug 31, 2018 · 2 comments
Assignees
Labels
Bug A bug in TypeScript

Comments

@pgraham
Copy link

pgraham commented Aug 31, 2018

Search Terms

I have found the following closed bugs that are related but not quite the same:

TypeStrong/ts-loader#405
#12762

Suggestion

I would like to be able to specify an empty files array when extending another tsconfig.json file in order to override a files array specified in the base config.

Use Cases

I have a base configuration file that includes all typescript sources, including tests, as well as a config file for local development:

tsconfig.json

{
    "compilerOptions": {
        ...
    },
    "include": [
        "src/**/*.ts",
        "spec/**/*.ts"
    ],
    "files": [
        "src/srv/config.json"
    ]
}

I then have a second configuration file for deployment builds that only includes sources. I also want to exclude the local config since an appropriate configuration file for the deployment environment is added by a downstream build step:

tsconfig.dist.json

{
    "extends": "./tsconfig.json",
    "include": [
        "src/**/*.ts"
    ],
    "files": []

However, attempting to compile using tsconfig.dist.json results in an error: tsconfig.dist.json:7:12 - error TS18002:

The 'files' list in config file '.../tsconfig.dist.json' is empty.

    "files": []

Checklist

My suggestion meets these guidelines:

  • [+] This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • [+] This wouldn't change the runtime behavior of existing JavaScript code
  • [+] This could be implemented without emitting different JS based on the types of the expressions
  • [+] This isn't a runtime feature (e.g. new expression-level syntax)
@pgraham
Copy link
Author

pgraham commented Aug 31, 2018

So I see now that this doesn't stop compilation and the output directory is as I expect. Maybe it would be nice to output a warning with a 0 exit code so that npm doesn't complain.

@pgraham
Copy link
Author

pgraham commented Aug 31, 2018

So a little bit more digging with this. A non-0 exit code from tsc, in this case, prevents me from composing commands with npm:

{
    "script": {
        "build": "npm run compile && npm run assemble && npm run deploy",
        "compile": "tsc -p tsconfig.dist.json",
        "assemble": "...",
        "deploy": "..."
    }
}

In a setup like this, npm halts execution when it encounters the non-0 exit code from tsc and so doesn't ever execute the assemble and deploy commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants