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

Function blankFlowSyntax

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

Source from the content-addressed store, hash-verified

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