-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
allowUnreachableCode has to be turned off due to third party libraries. #10233
Comments
|
Although bluebird does actually contain legitimately unreachable code: function toFastProperties(obj) {
/*jshint -W027,-W055,-W031*/
function FakeConstructor() {}
FakeConstructor.prototype = obj;
var l = 8;
while (l--) new FakeConstructor();
ASSERT("%HasFastProperties", true, obj);
return obj;
// Prevent the function from being optimized through dead code elimination
// or further optimizations. This code is never reached but even using eval
// in unreachable code causes v8 to not optimize functions.
eval(obj);
} It just has a good reason for it. |
I do have a .d.ts file for it. I know visual studio is picking it up because when I added the .d.ts file, this statement lost the red error squiggles:
I assume the compiler is picking it up or it would fail compilation as well (because it would not know what |
+1 Experiencing this inconvenience as well. |
If you are including the .js code from a different project, it is sort of your code at this point from the perspective of the compiler. the options are to include the .d.ts instead (.d.ts files have no statements, so no unreachable code by definition), or use a linter like tslint that allows you more fine grained control on what rules run on which files. All the compiler flags/options are compilation wide knobs, I do not think we intend to enable any file-level control at the time being. |
@mhegazy If that counts as "including" the code then that is fine, but most every JavaScript project out there has at least one other library in it via a package manager. If that is not supported then it makes the However, if that is the way it has to be because of Design Limitations and the fix being Too Complex then that is OK. As a side note, I do have the d.ts file included as well (from Definitely Typed.) |
I see the issue now. we have made a change in TS 2.0 to automatically load .js files from node_modules if as part of fixing #10460 we should be disabling this by default, so you only get it if you set If i may ask, do you have |
I do have a .js file in my compilation. Only one that has one line in it. (To declare a global variable because I could not get Typescript to do it. See this answer on SO if you want details http://stackoverflow.com/a/38906665/16241 ) |
This is a feature request:
I get the following error when I build my webpack project:
This is a problem in the
bluebird
npm library.But I don't want to have errors in my build. So I have to add this to my tsconfig.json to get this error to turn off:
But that is kind of a shame, because I don't want to allow unreachable code in my code, I just don't want to see errors for unreachable code that is in my node_modules. (I can't change node_module files without messing up my autobuild.)
So:
I am seeing code in node_modules inspected for unreachable code.
What I would expect (or want) to see is that node_modules is excluded from the unreachable code inspection.
In case it matters, here is my tsconfig.json:
The text was updated successfully, but these errors were encountered: