open-xml-templating / docxtemplater

Generate docx, pptx, and xlsx from templates (Word, Powerpoint and Excel documents), from Node.js or the browser. Demo: https://www.docxtemplater.com/demo. #docx #office #generator #templating #report #json #generate #generation #template #create #pptx #docx #xlsx #react #vuejs #angularjs #browser #typescript #image #html #table #chart
https://www.docxtemplater.com
Other
3.07k stars 350 forks source link

Question: Importing ExpressionParser in TypeScript. #741

Closed SegFault2017 closed 10 months ago

SegFault2017 commented 10 months ago

Question of Usage

Hi there! I'm currently working on using the expressionParser from docxtemplater/expressions.js. How do I import it in an import statement fashion.

From:

const expressionParser = require("docxtemplater/expressions.js");

Expected:

import expressionParser from `docxtemplater/expressions`

I see that there's a .d.ts file in the node module. Is there any @types/ modules for docXTemplater we need to install? Thanks.

edi9999 commented 10 months ago

That's strange, so you're saying the import doesn't work ? Are you using the latest version ?

SegFault2017 commented 10 months ago

No, the import does not work on my end. I am using "docxtemplater": "^3.42.7", and my node version is v.16.5. The tsc complier is complaining about Cannot find module 'docxtemplater/expressions' or its corresponding type declarations.

edi9999 commented 10 months ago

Did you run :

npm install angular-expressions ?

I have tried to reproduce your issue, but it seemed to work without a problem on typescript.

You can git clone the following repository and see for yourself, the docxtemplater/expresssions packages works fine for me :

git clone https://github.com/edi9999/typescript-docxtemplater.git

I'm using tsc --version = Version 4.9.5, maybe you're using an older version ??

SegFault2017 commented 10 months ago

Did you run :

npm install angular-expressions ?

I have tried to reproduce your issue, but it seemed to work without a problem on typescript.

You can git clone the following repository and see for yourself, the docxtemplater/expresssions packages works fine for me :

git clone https://github.com/edi9999/typescript-docxtemplater.git

I'm using tsc --version = Version 4.9.5, maybe you're using an older version ??

Yea, I was using an older version(< 4.9.5) of tsc. Thanks!

edi9999 commented 10 months ago

Which tsc were you using ? I'd like to, if possible make docxtemplater compatible also with older versions of typescript.

SegFault2017 commented 10 months ago

Which tsc were you using ? I'd like to, if possible make docxtemplater compatible also with older versions of typescript.

I was using tsc version 3.2.1.