Not able to access a function of external JS file from TS file

I have defined a function in external JS file.I am not able to use it in home.page.ts file. It is showing error as TypeError: Cannot read property ‘functionName’ of undefined

**index.html**


```
<body>
  <app-root></app-root>
  <script src="assets/multiLayerSource.js"></script>
</body>
```

**multiLayerSource.js**

var multiLayerSource;

var layersHT = [];

function SetLayerHT(arglayersHT) {

layersHT = arglayersHT;

}

**home.page.ts**

import { Component } from '@angular/core';
import { OnInit, Renderer, ViewChild  } from '@angular/core';
declare var multiLayerSource: any;
@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit {
layersHTP: any = [];
constructor() {}

ngOnInit() {
this.layersHTP.push( 'a', 'b', 'c', 'd' );
multiLayerSource.SetLayerHT(this.layersHTP);
}
}

It is showing error while trying to access SetLayerHT().
The error is :

TypeError: Cannot read property 'SetLayerHT' of undefined.

Please help.

Source: New feed
Source Url Not able to access a function of external JS file from TS file