* Rewrites bundled export statements that use inline `type` modifiers into a * plain value export plus a type-only export: * * export { type Config, ... }; * -> export type { Config, ... }; * * The inline form requires TypeScript 4.5, so emitting it narrows the range of * TypeScript ve
(types)
| 27 | * @returns {string} |
| 28 | */ |
| 29 | function rewriteInlineTypeExports(types) { |
| 30 | return types.replace(/^export \{([^}]*)\};$/gm, (statement, specifiers) => { |
| 31 | const parts = specifiers.split(',').map((s) => s.trim()); |
| 32 | const values = parts.filter((s) => s && !s.startsWith('type ')); |
| 33 | const names = parts |
| 34 | .filter((s) => s.startsWith('type ')) |
| 35 | .map((s) => s.slice(5)); |
| 36 | |
| 37 | if (names.length === 0) return statement; |
| 38 | |
| 39 | return [ |
| 40 | values.length > 0 && `export { ${values.join(', ')} };`, |
| 41 | `export type { ${names.join(', ')} };`, |
| 42 | ] |
| 43 | .filter(Boolean) |
| 44 | .join('\n'); |
| 45 | }); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Fixes the ES module type declarations file. |
no outgoing calls
no test coverage detected