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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With