(module string, isTypeOnly bool, names ...string)
| 52 | } |
| 53 | |
| 54 | func injectImport(module string, isTypeOnly bool, names ...string) guts.MutationFunc { |
| 55 | specs := make([]*bindings.ImportSpecifier, 0, len(names)) |
| 56 | for _, n := range names { |
| 57 | name, alias := splitNameAlias(n) |
| 58 | specs = append(specs, &bindings.ImportSpecifier{ |
| 59 | Name: name, |
| 60 | Alias: alias, |
| 61 | }) |
| 62 | } |
| 63 | decl := &bindings.ImportDeclaration{ |
| 64 | Module: module, |
| 65 | Named: specs, |
| 66 | IsTypeOnly: isTypeOnly, |
| 67 | } |
| 68 | return func(ts *guts.Typescript) { |
| 69 | ts.AppendImport(decl) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | // splitNameAlias parses entries of the form "Name" or "Name=Alias". |
| 74 | func splitNameAlias(s string) (name, alias string) { |
no test coverage detected
searching dependent graphs…