Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda