UNPKG

ttsc

Version:

General-purpose TypeScript-Go compiler, runtime, plugin host, and LSP host.

31 lines (30 loc) 1.48 kB
/** * Attributed JSON / JSONC readers for every configuration file ttsc owns. * * A bare `JSON.parse` failure reports a byte offset in an unnamed file, which * is unusable exactly where attribution matters most: an `extends` chain, where * any ancestor could be the source, and a watch session, which reprints the * same line on every save. Every ttsc-owned configuration read goes through * these helpers so the failure names its file and position in ttsc's own * diagnostic voice, like the neighbouring `ttsc: extended tsconfig not found: * …`. * * Comment, trailing-comma, and BOM removal is length-preserving (each removed * character becomes a space, each removed newline stays a newline), so the line * and column the JSON parser reports are the position in the file the user * actually edited rather than in a shortened intermediate string. */ /** * Read and parse a strict-JSON configuration file (`package.json`), naming it * on failure. * * A leading UTF-8 BOM is accepted, matching the tsconfig reader that closed * issue #216: the two readers are consulted for the same project and * disagreeing about a byte order mark would only surprise the user who hit it. */ export declare function readJsonFile(file: string): unknown; /** * Read and parse a JSONC (JSON with comments and trailing commas) configuration * file — tsconfig.json, jsconfig.json — naming it on failure. */ export declare function readJsoncFile(file: string): unknown;