Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import Tesseract into Angular2 (TypeScript)

I'm trying to import Tesseract into Angular2 (TypeScript). I can see it saved into the node_modules folder but when using

import { Tesseract } from '@types/tesseract.js';

it says:

[ts] Module '"c:/Users/black/Projects/projectCLI/tess/node_modules/@types/tesseract.js/index"' has no exported member 'Tesseract'.

In the index.d.ts file there is a namespace called Tesseract.

Is there some other way to import this or are we looking at this the wrong way?

I used npm install --save-dev @types/tesseract.js to install typescript Tesseract.

If there are any demo tutorials using tesseract can you please link them here?

thanks, in advance, for your help.

like image 276
The BrownBatman Avatar asked Mar 04 '17 09:03

The BrownBatman


1 Answers

You need to install the actual javascript module:
npm install tesseract.js --save

Also install @types declarations:
npm install @types/tesseract.js --save-dev

Finally do the folowing to import:
import * as Tesseract from 'tesseract.js'

To use the library check here

The @types command saves this type declaration file.
This is a namespace and all the contents of the actual module are declared within.When you do import * as aliasname from tessreact.js, you can use all the functions within the namespace as aliasname.functionname. Example is the test file for the same type declaration file.

like image 54
Suraj Rao Avatar answered Sep 24 '22 14:09

Suraj Rao