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

469
Views
¿Cómo debo hacer para obtener el texto ts cuando uso la API transpileModule?

Utilizo transpileModule para insertar un campo en Page-data , pero obtengo el resultado es un texto js, pierdo interface Account y opt: string | any ¿Cómo puedo hacer para obtener ts text?

 const ts = require('typescript') const factory = ts.factory const content = ` interface Account { id: number displayName: string version: 1 } Page({ data: { name: 'miser', }, }) Component({ data: { age: 18, }, }) function Component(opt: string | any) {} function Page(opt: any) {} ` const result = ts.transpileModule(content, { compilerOptions: {}, transformers: { before: [visitNodes], }, }) function visitNodes(ctx) { const visitor = node => { if ( ts.isPropertyAssignment(node) && node.name.escapedText === 'data' && node.parent.parent.expression.escapedText === 'Page' ) { const newNode = factory.createPropertyAssignment('haha', factory.createStringLiteral('ok')) node.initializer.properties.push(newNode) } return ts.visitEachChild(node, visitor, ctx) } return sourceFile => ts.visitNode(sourceFile, visitor) } console.log(result.outputText) // Page({ // data: { // name: 'miser', // haha: "ok", // }, // }); // Component({ // data: { // age: 18, // }, // }); // function Component(opt) { } // function Page(opt) { }
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!