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

Support "exclude" property in tsconfig.json #3188

Merged
merged 2 commits into from Jun 3, 2015

Conversation

Projects
None yet
@ahejlsberg
Copy link
Member

commented May 16, 2015

Implements #3043. A tsconfig.json file that doesn't specify a files property (and therefore implicitly references all *.ts files in all subdirectories) can now contain an exclude property that specifies a list of files and/or directories to exclude from the compilation. The exclude property must be an array of strings that each specify a file or folder name relative to the location of the tsconfig.json file. For example:

{
    "compilerOptions": {
        "out": "test.js"
    },
    "exclude": [
        "node_modules",
        "test.ts",
        "utils/t2.ts"
    ]
}

The exclude list does not support wilcards. It must simply be a list of files and/or directories.

@CyrusNajmabadi

This comment has been minimized.

Copy link
Contributor

commented May 16, 2015

This should probably have a name that ties it more close to 'fileNames'. i.e. 'excludedFileNames'. That way we know that this is supposed to complement that tsconfig property.

@ahejlsberg

This comment has been minimized.

Copy link
Member Author

commented May 17, 2015

The other property is called files, not fileNames. Since you can exclude both files and directories it would have to be excludedFilesAndDirectories which I think is over the top. I like the simple exclude.

@basarat

This comment has been minimized.

Copy link
Contributor

commented May 17, 2015

exclude.

excludes perhaps?

@yuit

This comment has been minimized.

Copy link
Contributor

commented May 17, 2015

I like excludes as well. If you decide to change, please update the variable and parameter name

@rcollette

This comment has been minimized.

Copy link

commented May 18, 2015

Meh. Seems to completely ignore the community feedback about globs.

@basarat

This comment has been minimized.

Copy link
Contributor

commented May 18, 2015

Seems to completely ignore the community feedback about globs.

Adding globbing support for matching might not be that hard if we can just copy in this battle tested code : https://github.com/isaacs/minimatch/blob/master/minimatch.js It is MIT https://github.com/isaacs/minimatch/blob/master/LICENSE

@rcollette

This comment has been minimized.

Copy link

commented May 18, 2015

I should have added more specifics. We keep all feature related code in the same directory. Unit tests are named *.spec.js Doing a build and excluding tests (or otherwise) doesn't work for us when files must be excluded by name and not by pattern.

@paulvanbrenk

This comment has been minimized.

Copy link
Contributor

commented May 19, 2015

👍
Though I can see the advantage of having globbbing, and adding a similar include property could prove to be useful.

@rbuckton

This comment has been minimized.

Copy link
Member

commented May 20, 2015

@ahejlsberg We discussed this briefly, but I have an alternative approach that supports "glob"-style pattern matching with recursive directories in this pull request: #3232.

@troyji

This comment has been minimized.

Copy link

commented May 21, 2015

I suspect tsconfig.json is destined for much broader use in the future. Using the simple key exclude could become ambiguous quickly. Consider a more specific key name.

@DanielRosenwasser

This comment has been minimized.

Copy link
Member

commented May 21, 2015

Pluralization ("excludes") would be better, but I'd too prefer a more specific name.

Merge branch 'master' into tsConfigExclude
Conflicts:
	src/compiler/sys.ts
@ahejlsberg

This comment has been minimized.

Copy link
Member Author

commented Jun 3, 2015

We're going with the simple exclude property for now, but we'll continue to refine #3232 with the eventual goal of supporting glob-style patterns. Anything we do in #3232 will be backwards compatible with the simple exclude list.

ahejlsberg added a commit that referenced this pull request Jun 3, 2015

Merge pull request #3188 from Microsoft/tsConfigExclude
Support "exclude" property in tsconfig.json

@ahejlsberg ahejlsberg merged commit ca4bf6b into master Jun 3, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@ahejlsberg ahejlsberg deleted the tsConfigExclude branch Jun 3, 2015

@tinganho

This comment has been minimized.

Copy link
Contributor

commented Jun 8, 2015

Does language service take exclude option into consideration? I happen to have the TS repo under node_modules/typescript and it takes a long time to autocomplete things.

I'm on VSCode 0.3 on a Mac. And I'm using the current master branch.

@mhegazy

This comment has been minimized.

Copy link

commented Jun 8, 2015

@tinganho this has been checked in recently. The Language Service support should be in 1.6 by the time it ships.

@basarat

This comment has been minimized.

Copy link
Contributor

commented Jul 14, 2015

@rbuckton I'd like to add support for this and completely remove atom-typescript's custom filesGlob support. Can you think of any use case where a glob is still needed if exclude is supported? Don't want to do a breaking change if I'll need to reimplement it 🌹

@basarat

This comment has been minimized.

Copy link
Contributor

commented Jul 14, 2015

Can you think of any use case where a glob is still needed if exclude is supported

Quick use case: user needs to include source from only a few folders. So ignore my last query 😉

@Mig1st4ck

This comment has been minimized.

Copy link

commented Jul 14, 2015

I use fileGlobs to order my ts files.

"filesGlob": [
        "./app/**/*.module.ts",
        "./app/**/*.ts",
        "!./node_modules/**/*.ts"
    ],
@mbalex99

This comment has been minimized.

Copy link

commented Jul 25, 2015

@Mig1st4ck your filesGlob reference is from Atom correct? This is not (yet) a native tsconfig feature right?

@basarat

This comment has been minimized.

Copy link
Contributor

commented Jul 25, 2015

@mbalex99 yes. It is not native

@HeikoH

This comment has been minimized.

Copy link

commented Jul 28, 2015

is this available in 1.5.3? Adding an exclude option to my tsconfig.json seems to have no effect when I run tsc

@HeikoH

This comment has been minimized.

Copy link

commented Jul 28, 2015

I guess not as it works as expected with a nightly (1.6) build

@JaKXz

This comment has been minimized.

Copy link

commented Nov 10, 2015

It would be great if the exclude property supported globs. I'm sure that's been said somewhere, but I'm trying to do something similar to @Mig1st4ck and not having luck excluding files with the filesGlob property and the ! property (under the assumption that filesGlob handles the ! glob operator and excludes those files).

EDIT: on second thought, maybe my issue is only exclusive to TypeStrong/atom-typescript#558... apologies for noise...

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.