Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate Function Implementation

I have one file, app.ts under my scripts folder, that gets copied to wwwroot/scripts by a gulp task. After the gulp task runs, I now also have a wwwroot/scripts/app.ts file, in which the sole function is red-underlined as duplicate. Is this normal, or is my gulp task, below, declared incorrectly?

var paths = {
    scripts: ["scripts/**/*.js", "scripts/**/*.ts", "scripts/**/*.map"]
};

gulp.task("default", function() {
    gulp.src(paths.scripts).pipe(gulp.dest("wwwroot/scripts"));
});

I see the raw app.ts file, from the root scripts folder also gets built into *.js and *.js.map files. Could this have something to do with the 'false positive' duplicate function?

like image 783
ProfK Avatar asked Nov 07 '19 11:11

ProfK


People also ask

What is overload in TypeScript?

In TypeScript, function overloading, or method overloading, is the ability to create multiple methods with the same name and same return type, but a different number of parameters or different parameter types. So essentially, method overloading is allowed when – Function name is same.

What is function overloading in JavaScript?

In programming, function overloading refers to the concept where multiple functions with the same names can have different implementations. However, in JavaScript, if there are multiple functions with the same name, the function that is defined at the last gets executed.

Does TypeScript have function overloading?

Function overloading in TypeScript lets you define functions that can be called in multiple ways. Using function overloading requires defining the overload signatures: a set of functions with parameter and return types, but without a body.


1 Answers

Don't copy the .ts files. You only need the compiled .js files in the scripts directory (unless you are doing something unusual with TypeScript source from there).

Then in your tsconfig.json file, add an exclude directive to exclude wwwroot/scripts/**/* in your IDE.

like image 102
Josh Wulf Avatar answered Oct 07 '22 07:10

Josh Wulf