/** * Text-only analysis of SSJS source for the embedded TypeScript service: ESLint-style global * comments, prototype/static polyfills and the comment ranges used to filter diagnostics and * remap definitions. Nothing here depends on TypeScript or on the runtime environment. */ /** * Parses ESLint-style global comments from SSJS source text and returns a * TypeScript ambient declaration string for all declared names. * * Supported forms: * /* global DEBUG, deKey * / * /* globals DEBUG, deKey * / * /* global DEBUG:readonly, deKey:writable * / * * Qualifiers (`:readonly`, `:writable`) are accepted for ESLint compatibility * but ignored — all names are declared as `any` for the TS checker. * * Returns an empty string when no global comments are present. * @param text - SSJS source text to scan * @returns TypeScript `declare var` statements, or an empty string */ export declare function parseGlobalCommentDeclarations(text: string): string; /** * Scans SSJS source for prototype polyfills of the form * `Ctor.prototype.method = ...` and returns TypeScript interface-merge * declarations that add each polyfilled method to the matching built-in * interface from `sfmc-globals.d.ts`. * * Because the bundled `sfmc-globals.d.ts` intentionally declares only the * SSJS-supported subset of built-in methods (no `Array.prototype.forEach`, * `String.prototype.startsWith`, …), polyfilling an unsupported method would * otherwise raise `Property 'X' does not exist` on both the assignment and * every later call. Merging the polyfilled members back into the interface * teaches the checker that those methods now exist for this document. * * Each polyfilled member is emitted as a *method signature* (not a bare * `: any` property) so hover reports `(method) String.startsWith(...)` rather * than `(property) … : any`. When the polyfill is assigned a function * expression, the function's own parameter names are reused — typed from the * polyfill's `@param {Type}` / `@returns {Type}` JSDoc when present, otherwise * `any` — and any JSDoc block immediately preceding the assignment is forwarded * so the checker surfaces the documented `@param` / `@returns` text on hover. * The polyfill's body is still type-checked normally and unrelated diagnostics * are preserved. * * Returns an empty string when no prototype polyfills are present. * @param text - SSJS source text to scan * @returns TypeScript interface-merge statements, or an empty string */ export declare function parsePolyfillDeclarations(text: string): string; /** * Compute the `[start, end)` offset ranges of every JSDoc block comment * (`/** … *\/`) in the given source text. * @param text - full document text * @returns an array of `[start, end)` offset tuples */ export declare function jsdocCommentRanges(text: string): Array<[number, number]>; /** * Determine whether `offset` falls within any of the supplied comment ranges. * @param offset - character offset to test * @param ranges - JSDoc comment ranges from {@link jsdocCommentRanges} * @returns true when the offset is inside a JSDoc comment */ export declare function isInsideJsdoc(offset: number, ranges: Array<[number, number]>): boolean; /** * Compute the `[start, end)` offset ranges of every prototype-polyfill * assignment body — `Ctor.prototype.method = [Ctor.prototype.method ||] function (…) { … }`. * * The self-guarded form (`X = X || function () {}`) defeats TypeScript's * contextual `this` typing under `noLib:true`: the declared `this: any[]` * parameter on the merged interface member does not flow into the function * operand of the `||`, so a body reading `this.length` or doing `return this` * raises spurious ts2339 / ts2322. These are known-good SSJS polyfills, so the * `this`-related diagnostics inside their bodies are suppressed. * @param text - full document text * @returns an array of `[start, end)` offset tuples spanning each assignment body */ export declare function prototypePolyfillBodyRanges(text: string): Array<[number, number]>; /** * Read the method identifier at `offset` inside a generated `.polyfills.d.ts` * interface member so the reference remap can locate the matching prototype * assignment in the source document. * @param text - the polyfills declaration file content * @param offset - the reference text-span start within that file * @returns the method name at the offset, or an empty string */ export declare function prototypeMethodNameFor(text: string, offset: number): string; /** * Determine whether `offset` falls inside a line (`// …`) or block (`/* … *\/`) * comment in the given source text. Used to detect when TypeScript resolved a * prototype-polyfill definition into its leading JSDoc block instead of the * assignment identifier, so the definition can be redirected to the code line. * @param text - source text to scan * @param offset - character offset to test * @returns true when the offset lies within a comment */ export declare function isOffsetInsideComment(text: string, offset: number): boolean; /** * Locate the `…prototype.` assignment for a polyfilled method in the * document source and return the text span covering the method name, so * go-to-definition lands on the polyfill itself. * @param text - document source text * @param method - the polyfilled method name * @returns the method-name text span, or null if not found */ export declare function findPrototypeAssignmentSpan(text: string, method: string): { start: number; length: number; } | undefined; //# sourceMappingURL=source-analysis.d.ts.map