MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / blankFlowSyntax

Function blankFlowSyntax

src/extraction/languages/typescript.ts:60–70  ·  view source on GitHub ↗
(source: string, filePath?: string)

Source from the content-addressed store, hash-verified

58 * pragma — the ones `detectLanguage` sends here from `.js`.
59 */
60export function blankFlowSyntax(source: string, filePath?: string): string {
61 if (!filePath || !/\.(?:jsx?|mjs|cjs)$/.test(filePath) || !hasFlowPragma(source)) return source;
62 return source
63 .replace(/\{\|/g, '{ ')
64 .replace(/\|\}/g, ' }')
65 .replace(/([:<,]\s*)\?(?=[\w$({[])/g, '$1 ')
66 .replace(/\bimport\s+typeof\b/g, (m) => 'import' + ' '.repeat(m.length - 'import'.length))
67 .replace(/\bopaque(?=\s+type\b)/g, ' ')
68 // An inexact object type's bare `...` (`{a: T, ...}`) — never a value spread.
69 .replace(/\.\.\.(?=\s*[},])/g, ' ');
70}
71
72/** Whether the file writes `export type *` anywhere: most files don't, and skip the rest. */
73const EXPORT_TYPE_STAR_HINT = /export\s+type\s*\*/;

Callers 2

flow-js.test.tsFile · 0.90
typescript.tsFile · 0.85

Calls 1

hasFlowPragmaFunction · 0.90

Tested by

no test coverage detected