Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Ts-node returning undefined for regular expression

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

enter image description here

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*"
  ]
}


about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!