FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support "exclude" property in tsconfig.json by ahejlsberg · Pull Request #3188 · microsoft/TypeScript · GitHub

Support "exclude" property in tsconfig.json - #3188

Merged
Anders Hejlsberg (ahejlsberg) merged 2 commits into
masterfrom
tsConfigExclude
Jun 3, 2015
Merged

Support "exclude" property in tsconfig.json#3188
Anders Hejlsberg (ahejlsberg) merged 2 commits into
masterfrom
tsConfigExclude

Conversation

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
Contributor

exclude.

excludes perhaps?

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@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.

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Ron Buckton (@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 🌹

Copy link
Copy Markdown
Contributor

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 😉

Copy link
Copy Markdown

I use fileGlobs to order my ts files.

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

Maximilian Alexander (@mbalex99) yes. It is not native

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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 Miguel Couto (@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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.


Back | FazBrowse Home | New Git URL