Closed tdjastrzebski closed 4 years ago
Answering own question:
import XRegExp from 'xregexp';
My suggestion: as typescript becomes more and more popular it may make a sense to maintain current type definitions and release together with the javascript package.
I'm currently doing
// @ts-ignore
import XRegExp from "xregexp";
to avoid the types errors , would be nice to contrib to the types.
Answering own question:
- set esModuleInterop = true in tsconfig.json
- use
import XRegExp from 'xregexp';
- do not install @types/xregexp - as of August 2019 there is no current version available
My suggestion: as typescript becomes more and more popular it may make a sense to maintain current type definitions and release together with the javascript package.
@tdjastrzebski There is a pull request for an update to @types/xregexp. Once it is merged it will provide definitions for XRegExp v4.3.0. https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43115
Looks like the mentioned PR has been merged!
How do I correctly use xregexp in typescript? In a new console nodejs app I did:
npm init
npm install xregexp --save-dev
On the line where I try to use XRegExp received error reads:TypeError: xregexp_1.default is not a function
I tried to install type definition as well:npm install @types/xregexp --save-dev
but this did not help. I think there is version mismatch anyway - latest types is version 3.0.30 (vs xregexp@4.2.4). I does not seem to matter how I import XRegExp (see #218). I tried:import * as xregexp from 'xregexp';
import { XRegExp } from 'xregexp';
but the error is always the same. What am I missing?