I'm trying to work on this TypeScript project. I've written a tsconfig.json
, and when I try running from the command line, everything works fine.
However, when I try editing the project's files in Visual Studio Code, Visual Studio, Sublime, or WebStorm, those settings don't appear to be getting applied. Here's a few things that are special about this tsconfig.json
in case it helps:
- It uses the
strict
flag. - It uses
noImplicitAny
andstrictNullChecks
for good measure. - It uses path mapping (i.e. the
paths
andbaseUrl
fields).
How can I get this working?
First: make sure your
tsconfig.json
is free of syntax errorsYou might add a field to your configuration file, but JSON is a very picky language, so while you may have previously run with
tsc
, you might not have noticed yourtsconfig.json
was recently broken.Second: make sure that your files are being included in the project configuration
First, check that your
tsconfig.json
is including your files by runningtsc
using the--listFiles
flag.If the files are not listed by
tsc --listFiles
, you can add them to yourtsconfig.json
using a set of top-level fields:The
include
&exclude
fieldsThe easiest way is to specify a series of patterns (specifically "globs") to match folders & files using the
"include"
and"exclude"
fields. This can be an entire folder like./src
.For example:
The
files
fieldYou can specify the list of files using the
"files"
field. If you have a single file that transitively imports everything else, then you can just list that entry-point. But make sure you end up actually importing those files.For example: