0

I have 2 .ts files.

index_num_bin.ts:

******

let arr: number[] = [1, 2, 3, 4, 5, 6, -7];
const t = 10;
arr = arr.sort();

console.log(indexOfN(arr, t));

index_num_bin_recur.ts:

let arr: number[] = [1, 2, 3, 4, 5, 6, -7];
const t = 10;
arr = arr.sort();

console.log(indexOfN(arr, t));

The second one has nothing but the ending of the previous one yet. However, I see an error: error_image_1st_file and vice versa: error_image_2nd_file It says like these files are in fact in the one file and the variable is already declared in another file and these 2 files fully see all the global scope of each other. And the same error with these variables in these two files(.

I searched for some scope problems but I couldn't find the right answer.

3kShoter
  • 5
  • 3
  • Possible duplicate of [this](https://stackoverflow.com/questions/64835670/how-to-tell-tsc-that-script-files-will-not-share-scope-and-ignore-redeclarations). Also I notice that none of your files have imports / exports, so I don't think there is anything to tell the compiler that these are modules which would have their own scope (otherwise, both file's contents would run in the global scope, and hence the re-declaration) – Jthorpe Jan 17 '23 at 15:09
  • Yeah, it worked, i got you. – 3kShoter Jan 17 '23 at 16:05

0 Answers0