{"version":3,"sources":["../../src/checkers/tscUtils.ts"],"sourcesContent":["import type ts from 'typescript'\n\n/**\n * Wrap a `SolutionBuilderWithWatchHost` so that when a referenced project's\n * tsconfig fails to parse, we force `compilerOptions.noEmit` to `true` instead\n * of letting TS fall back to defaults (which include `noEmit: false`).\n *\n * `createSolutionBuilderWithWatch` takes its emit decisions from each referenced\n * project's own `compilerOptions`. If a referenced tsconfig is truncated or\n * mid-write at the moment TS reads it (which can happen e.g. when a dev tool\n * rewrites tsconfigs at runtime), TS falls back to default options — and the\n * default is `noEmit: false`, so the build host writes `.js` files next to\n * sources. See https://github.com/nuxt/nuxt/issues/32872.\n *\n * We deliberately only override when parsing produced errors: forcing\n * `noEmit: true` on every parsed project would break valid `tsc --build`\n * graphs, since composite referenced projects must emit declarations.\n */\nexport function forceNoEmitOnSolutionBuilderHost<\n H extends {\n getParsedCommandLine?: ts.SolutionBuilderHostBase['getParsedCommandLine']\n },\n>(ts: typeof import('typescript'), host: H): H {\n const parseConfigHost: ts.ParseConfigFileHost = {\n useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,\n readDirectory: ts.sys.readDirectory,\n fileExists: ts.sys.fileExists,\n readFile: ts.sys.readFile,\n getCurrentDirectory: ts.sys.getCurrentDirectory,\n onUnRecoverableConfigFileDiagnostic: () => {},\n }\n\n const original = host.getParsedCommandLine?.bind(host)\n\n host.getParsedCommandLine = (fileName: string) => {\n const parsed = original\n ? original(fileName)\n : ts.getParsedCommandLineOfConfigFile(\n fileName,\n undefined,\n parseConfigHost,\n )\n if (parsed && parsed.errors.length > 0) {\n parsed.options.noEmit = true\n }\n return parsed\n }\n\n return host\n}\n"],"mappings":"AAkBO,SAAS,iCAId,IAAiC,MAAY;AAtB/C;AAuBE,QAAM,kBAA0C;AAAA,IAC9C,2BAA2B,GAAG,IAAI;AAAA,IAClC,eAAe,GAAG,IAAI;AAAA,IACtB,YAAY,GAAG,IAAI;AAAA,IACnB,UAAU,GAAG,IAAI;AAAA,IACjB,qBAAqB,GAAG,IAAI;AAAA,IAC5B,qCAAqC,MAAM;AAAA,IAAC;AAAA,EAC9C;AAEA,QAAM,YAAW,UAAK,yBAAL,mBAA2B,KAAK;AAEjD,OAAK,uBAAuB,CAAC,aAAqB;AAChD,UAAM,SAAS,WACX,SAAS,QAAQ,IACjB,GAAG;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACJ,QAAI,UAAU,OAAO,OAAO,SAAS,GAAG;AACtC,aAAO,QAAQ,SAAS;AAAA,IAC1B;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}