<p dir="auto">I am unsure if this is caused by TS eagerly loading <a href="https://github.com/Microsoft/TypeScript/blob/master/src/compiler/program.ts#L751">all syntax trees</a> or by the tsserver eagerly loading <a href="https://github.com/Microsoft/TypeScript/blob/master/src/server/editorServices.ts#L413">all symbols</a> (which btw seems crazy to me) but I think the tsserver should check how large a project is (or how much memory is already <a href="https://github.com/Microsoft/TypeScript/blob/master/src/compiler/sys.ts#L23">used</a>) and fail gracefully.</p>
<p dir="auto">I have a JavaScript project with little code but a lots of dependencies like <code class="notranslate">node_modules</code> and <code class="notranslate">bower_components</code> as well as files that get generated into a <code class="notranslate">temp</code> folder (on server start). I am aware of the exclude-property and the <a href="https://github.com/Microsoft/TypeScript/blob/master/src/compiler/commandLineParser.ts#L569">default</a> <a href="https://github.com/Microsoft/TypeScript/blob/master/src/compiler/commandLineParser.ts#L591">excludes</a>, but the challenge is to provide guidance to the user to use them.  I have no chance to ask tsserver how many files are included by a project because it crashes already with the first <code class="notranslate">open-file</code> request.</p>
<p dir="auto">A diagnostics message ala <code class="notranslate">too many files (foo/jsconfig.json, files: [...]),</code> would be much appreciated because otherwise we are going to duplicate a lot of logic on our (VS Code) end for such checks (and the server will still crashes).</p>
<p dir="auto">An extension to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="54532184" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/1692" data-hovercard-type="pull_request" data-hovercard-url="/microsoft/TypeScript/pull/1692/hovercard" href="https://github.com/microsoft/TypeScript/pull/1692">#1692</a></p>
<p dir="auto">Our ts project uses a grunt-based build system, with bower dependencies for the application and node_modules for build-tools. We will need the ability to exclude node_modules and bower_components from the build by default (unless files are referenced via /// ).</p>
<p dir="auto">This causes an issue: we have end-to-end tests running in protractor, as well as unit tests running in jasmine, and unless we have the ability to exclude node_modules and bower_components, both will be parsed and we'll get duplicate definition errors.</p>
<p dir="auto">In Visual Studio today, this is why we need to exclude both bower_components and node_modules from the project, because visual studio automatically parses all files in the project with no way to exclude them except to keep them out of the project altogether.</p>
<p dir="auto">A number of third party tools have started to support tsconfig.json, and one thing I've noticed is that most of them support some sort of extension to tsconfig.json that supports file globs. I propose we just add support into the spec for file globs. For the version of typescript on npm, we can just depend on the appropriate file glob libraries in the npm ecosystem. For the Visual Studio embedded version of TypeScript, just embed the glob libraries that are needed statically in the installation.</p>
<p dir="auto">As a fallback, if the notion of including a third party glob library is a non-starter, then the following fallback supporting a subset of the glob patterns would solve our problem at least partially.</p>
<p dir="auto">Fallback:<br>
Support both file and directory inclusions and exclusions in the files property:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="files: [
  'app/', (equivalent to 'app/**/*.ts')
  '!e2e/', (equivalent to '!e2e/**/*.ts')
  '!node_modules/',
  '!app/bower_components/',
  '!app/vendor/fooLib/fooLib.ts'
]"><pre class="notranslate"><code class="notranslate">files: [
  'app/', (equivalent to 'app/**/*.ts')
  '!e2e/', (equivalent to '!e2e/**/*.ts')
  '!node_modules/',
  '!app/bower_components/',
  '!app/vendor/fooLib/fooLib.ts'
]
</code></pre></div>