I encountered a typescript error while running my code stating that "require" is not a function. To resolve this, I declared the function beforehand; however, a new typescript error now occurs saying "Modifiers cannot appear here." Can anyone assist me with fixing this issue?
import { Injectable, ValueProvider } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class DataService {
edge: any;
constructor() {
declare function require(name: string); // Facing an issue with "Modifiers cannot appear here."
this.edge = require('edge');
}
getData(type: string, method: string) {
var data = this.edge.func({
assemblyFile: 'C:\Program Files\Common Files\Siemens\Automation\Simatic OAM\bin\CC.CommonInterfaces.dll',
typeName: `CC.CommonInterfaces.${type}`,
methodName: `${method}`
});
return data(null, function(error, result) {
if (error) throw error;
console.log(result);
return result;
});
}
}