Function tsStripImports

  • Strips all import statements from a given TypeScript code string.

    Parameters

    • code: string

      The TypeScript code to strip import statements from.

    Returns string

    The TypeScript code without import statements.

    Example

    const code = `
    import { Component } from '@angular/core';
    import { OnInit } from '@angular/core';
    const a = 1;
    `.trim()
    tsStripImports(code)
    //=> 'const a = 1;'

Generated using TypeDoc