-1

I am trying to use JsBarcode (JavaScript only features) in the TypeScript file. But, I am getting the following error,

enter image description here

I looked at possible solutions and I could not find a d.ts for JsBarcode.

Note:

URL of JsBarcode: https://github.com/lindell/JsBarcode

I have referenced the js files correctly in my HTML page,

<script src="Scripts/JsBarcode.all.min.js"></script>
<script src="Scripts/app.js"></script>

Any suggestion on how to include JsBarcode in my TypeScript file is appreciated.

JGV
  • 5,037
  • 9
  • 50
  • 94
  • 4
    Possible duplicate of [How use an external non-typescript library from typescript without .d.ts?](http://stackoverflow.com/questions/27417107/how-use-an-external-non-typescript-library-from-typescript-without-d-ts) – Mike Cluck Feb 10 '16 at 21:29

1 Answers1

0

Based on the link provided in comment by Mike, here is how I fixed the issue,

Declared a variable called 'JsBarcode' outside of my typescript class and it did the trick.

declare var JsBarcode: any;

class PrintingConfig {

...

private PrintLabel(): boolean {

        var instance: PrintingConfig = this;        

        if (instance.idTextBox.value.trim().length > 0) {
            JsBarcode("#IDBarcode", instance.idTextBox.value.trim(), {
                width: 1,
                height: 16              
            });            
        }

        ...
}
JGV
  • 5,037
  • 9
  • 50
  • 94