tamino-martinius / node-ts-dedent

TypeScript package which smartly trims and strips indentation from multi-line strings
MIT License
159 stars 8 forks source link

Handle interpolations properly #21

Closed jasonkuhrt closed 2 years ago

jasonkuhrt commented 3 years ago
import dedent from 'ts-dedent'

const fieldDocs = dedent`
  * a
  * b
  * c
`

const a = dedent`
  /**
   ${fieldIntro()}
   *
   ${fieldDocs}
   *
   ${fieldExample()} 
   */
`

function fieldIntro() {
  return dedent`
    * 0
  `
}
function fieldExample() {
  return dedent`
    * d
  `
}

console.log(a)

Expected

/**
 * 0
 *
 * a
 * b
 * c
 *
 * d 
 */

Actual

/**
 * 0
 *
 * a
* b
* c
 *
 * d 
 */