Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have VS2017 work with a tsconfig.json file in a sub-directory?

I currently have this folder structure in an ASP.Net Core 2.1 Web Project, open in VS2017:

-Project.Web -ClientApp -tsconfig.json

Visual Studio fails to find the tsconfig.json and so tries to use it's own default TypeScript settings.

The reason I'm trying to do this is, I'm following the new ASP.Net 2.1 approach for integrating with React.

The guide is great, except what it describes doesn't involve TypeScript.

So I switched to create-react-app-typescript, and then "ejected" from the CRA so I have full control over the configuration.

That left me with the tsconfig.json in the ClientApp directory, which is the logical place for it to be, but Visual Studio 2017 doesn't seem to support it.


1 Answers

I moved the tsconfig in to the root for the project, and tweaked the paths in various places. It's not a perfect answer, but it's what I went with.

I changed tsconfig.json:

"baseUrl": ".", to "baseUrl": "./ClientApp",

"rootDir": "src", to "rootDir": "ClientApp/src",

I also had to tell the TS tooling (primarily via WebPack) about it's new location:

appTsConfig: resolveApp('tsconfig.json'), to appTsConfig: resolveApp('../tsconfig.json'),

appTsProdConfig: resolveApp('tsconfig.prod.json'), to appTsProdConfig: resolveApp('../tsconfig.prod.json'),

All pretty obvious stuff.

I didn't find any documentation on exactly what VS2017 supports when it comes to tsconfig.json files.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!