open-xml-templating/docxtemplater

Question: Importing ExpressionParser in TypeScript.

SegFault2017 opened this issue · 6 comments

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.

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

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.

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 ??

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!

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

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.