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
Merged

Conversation

ahejlsberg
Copy link
Member

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
Copy link
Contributor

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
Copy link
Member Author

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
Copy link
Contributor

basarat commented May 17, 2015

exclude.

excludes perhaps?

@yuit
Copy link
Contributor

yuit commented May 17, 2015

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

@rcollette
Copy link

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

@basarat
Copy link
Contributor

basarat 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
Copy link

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
Copy link
Contributor

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

@rbuckton
Copy link
Member

@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
Copy link

troyji 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
Copy link
Member

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

Conflicts:
	src/compiler/sys.ts
@ahejlsberg
Copy link
Member Author

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
Support "exclude" property in tsconfig.json
@ahejlsberg ahejlsberg merged commit ca4bf6b into master Jun 3, 2015
@ahejlsberg ahejlsberg deleted the tsConfigExclude branch June 3, 2015 22:35
@tinganho
Copy link
Contributor

tinganho 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
Copy link
Contributor

mhegazy 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
Copy link
Contributor

basarat 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
Copy link
Contributor

basarat 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
Copy link

I use fileGlobs to order my ts files.

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

@mbalex99
Copy link

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

@basarat
Copy link
Contributor

basarat commented Jul 25, 2015

@mbalex99 yes. It is not native

@HeikoH
Copy link

HeikoH 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
Copy link

HeikoH commented Jul 28, 2015

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

@JaKXz
Copy link

JaKXz 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.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet