title: Why Does Tsconfig Need To Compile Javascript Files Angular
body: <p>I would like to use canvasjs for some charts on an Angular project that i'm making (<a href="https://canvasjs.com/angular-charts/" rel="nofollow noreferrer">https://canvasjs.com/angular-charts/</a>)</p>
  
  <p>To do so i have downloaded their javascript file and imported it into one of my component as suggested.</p>
  
  <pre><code>import * as CanvasJS from './../../../assets/canvasjs.min.js';
  </code></pre>
  
  <p>However I sometimes receive when I try to run my application using npm start</p>
  
  <pre><code>ERROR in src/app/Components/multi-camera-view/multi-camera-view.component.ts(2,27): error TS6143: Module './../../../assets/canvasjs.min.js' was resolved to '/src/assets/canvasjs.min.js', but '--allowJs' is not set.
  </code></pre>
  
  <p>After a quick bit of reading, allowJs allows the ts compiler to compile javascript files, but why the heck does it need to compile those if they're already in javascript?</p>
  
  <p>Browsers can't read typescript but they can read javascript. So why does it need to compile it?</p>
  
  <p>I tried adding the allowJs flag in my tsconfig.json file at the root</p>
  
  <pre><code>{
    "compileOnSave": false,
    "compilerOptions": {
      "outDir": "./dist/out-tsc",
      "sourceMap": true,
      "declaration": false,
      "moduleResolution": "node",
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "target": "es5",
      "allowJs": true,
      "typeRoots": [
        "node_modules/@types"
      ],
      "lib": [
        "es2017",
        "dom"
      ]
    }
  }
  </code></pre>
  
  <p>But then i just got the error:</p>
  
  <pre><code>ERROR in error TS5055: Cannot write file '/src/assets/canvasjs.min.js' because it would overwrite input file.
    Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
  </code></pre>
  
  <p>I visited the link and set noEmit to true, but then my application would build fine but wouldn't run. So, what's the best way to use this javascript file?</p>
  
  <p>Thanks!</p>