I am trying obtain matches for a particular string using regex in my js script. The files I depend on are written in typescript. Below is a sample of the script to match text within curly braces:
//sampleRegex.ts
const dynamicRegex = /{(\w+)}/gmi;
const [v1] = 'hello {type}'.matchAll(dynamicRegex)
console.log(v1);
When I attempt to run the script using ts-node ts-node sampleRegex.ts, undefined is logged to the screen however when I try the exact same script in a js file with node sampleRegex.js I get the appropriate output shown below
I am trying to figure out why that is and how to get is in ts-node
//tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": [
"es6",
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": false,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"sourceMap": true,
"noFallthroughCasesInSwitch": true,
"typeRoots": [
"@types",
"node_modules/@types"
]
},
"include": [
"src"
],
"exclude": [
"src/sw*"
]
}