Skip to content

Referenced file is included even if its in the tsconfig exclude list #15417

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

Closed
fis-cz opened this issue Apr 27, 2017 · 11 comments
Closed

Referenced file is included even if its in the tsconfig exclude list #15417

fis-cz opened this issue Apr 27, 2017 · 11 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@fis-cz
Copy link

fis-cz commented Apr 27, 2017

TypeScript Version: 2.2.1 / Visual Studio Extension

Hello,

I would like to ask why referenced file is included to the compilation all the time even if it excluded in the tsconfig.

I am doing something like this:

I have 4 tsconfig files:

  • tsconfig.json
    • extends tsconfig.Debug.json or tsconfig.Release.json based on VS solution configuration. Its auto-generated file written during the VS project pre-build task
rem *** Prepare tsconfig.json based on the solution configuration (Debug/Release)
echo // This file is generated automatically based on the Visual Studio Solution configuration. > "$(ProjectDir)tsconfig.json"
echo // To configure TypeScript transpiller for given solution configuration use the tsconfig.common.json, tsconfig.Debug.json and tsconfig.Release.json >> "$(ProjectDir)tsconfig.json"
echo { "compileOnSave": true, "extends" : "./tsconfig.$(ConfigurationName).json" } >> "$(ProjectDir)tsconfig.json"

and simply contains just:

// This file is generated automatically based on the Visual Studio Solution configuration. 
// To configure TypeScript transpiller for given solution configuration use the tsconfig.common.json, tsconfig.Debug.json and tsconfig.Release.json 
{ "compileOnSave": true, "extends" : "./tsconfig.Debug.json" } 
  • tsconfig.common.json
    • common configuration independent on the VS solution configuration
  • tsconfig.Debug.json
    • extends tsconfig.common.json and includes options related to debug version only (i.e. generating map files)
  • tsconfig.Release.json
    • extends tsconfig.common.json and includes only options related to release version only (i.e. removeComments)

so I can do a conditional compilation of the project files, because I am also specifying in

tsconfig.Debug.json

   ...
   "exclude": [ ..., "/**/*.Release.ts" ]

tsconfig.Release.json

   ...
   "exclude": [..., "/**/*.Debug.ts"]

so basically all files with .Release.ts extension are excluded during the debug build and vice versa.

The problems comes when I have i.e. file with constants (this is just example) such as

constants.Debug.ts

   ...
   export const buildType: string = "Debug";
   ...

constants.Release.ts

   export const buildType: string = "Release";
   ...

which I am referencing in another file:

///<reference path="./constants.Debug.ts" />
///<reference path="./constants.Release.ts" />
...

Expected behavior:
I would expect that one of referenced files will not included to the project compilation (based on the build configuration) as it is excluded in the tsconfig

Actual behavior:
Both files are included so "Cannot redeclare block-scoped variable..." error is shown.

@fis-cz fis-cz changed the title Referenced file is included even if its in the tsconfig ignore list Referenced file is included even if its in the tsconfig exclude list Apr 27, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Apr 27, 2017

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Apr 27, 2017
@fis-cz
Copy link
Author

fis-cz commented Apr 27, 2017

Thanks for response. Is there any way how to get around it? Because I need to reference the file in order it is included in the generated js before functions are used.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 27, 2017

Would having different tsconfig.json files based on the setup be a possibility?

@fis-cz
Copy link
Author

fis-cz commented Apr 27, 2017

I am sorry, I don't see the idea. It probably would be possible but it also would be less comfortable for developers than the current solution.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 27, 2017

Configuration inheritance can simplify the process.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 27, 2017

otherwise, #3538 might be what you are looking for.

@fis-cz
Copy link
Author

fis-cz commented Apr 27, 2017

Thats exactly what I am doing. I inherit tsconfig.json from tsconfig.Debug.json which inherits tsconfig.Common.json. It works well until there is <reference path... inside of one of .ts files as exclusion of that referenced file is not taken into account.

We should be able to conditionally exclude reference in my opinion.

#3538 does not help at all.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 27, 2017

do not mix references and tsconfig files. that would be my recommendation.

@fis-cz
Copy link
Author

fis-cz commented Apr 27, 2017

Anybody has an idea how to get around this problem?

@fis-cz
Copy link
Author

fis-cz commented May 10, 2017

Nobody was trying to solve this issue? Omg :)

@mhegazy
Copy link
Contributor

mhegazy commented May 24, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed May 24, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

2 participants