microsoft/TypeScript · error · Error

No sourcemap files should be generated if inlineSourceMaps w

Error message

No sourcemap files should be generated if inlineSourceMaps was set.

What it means

Thrown by doSourcemapBaseline when options.inlineSourceMap is true but the compilation result still contains separate sourcemap files (result.maps.size > 0) and declaration maps are not enabled. With inline sourcemaps the map is embedded in the JS output, so no standalone .map files should exist.

Source

Thrown at src/harness/harnessIO.ts:868

                lastIndexWritten ??= -1;
                if (lastIndexWritten + 1 < codeLines.length) {
                    if (!((lastIndexWritten + 1 < codeLines.length) && (codeLines[lastIndexWritten + 1].match(/^\s*[{|}]\s*$/) || codeLines[lastIndexWritten + 1].trim() === ""))) {
                        typeLines += "\r\n";
                    }
                    typeLines += codeLines.slice(lastIndexWritten + 1).join("\r\n");
                }
                typeLines += "\r\n";
                yield [checkDuplicatedFileName(unitName, dupeCase), Utils.removeTestPathPrefixes(typeLines)];
            }
        }
    }

    export function doSourcemapBaseline(baselinePath: string, options: ts.CompilerOptions, result: compiler.CompilationResult, harnessSettings: TestCaseParser.CompilerSettings): void {
        const declMaps = ts.getAreDeclarationMapsEnabled(options);
        if (options.inlineSourceMap) {
            if (result.maps.size > 0 && !declMaps) {
                throw new Error("No sourcemap files should be generated if inlineSourceMaps was set.");
            }
            return;
        }
        else if (options.sourceMap || declMaps) {
            if (result.maps.size !== ((options.sourceMap ? result.getNumberOfJsFiles(/*includeJson*/ false) : 0) + (declMaps ? result.getNumberOfJsFiles(/*includeJson*/ true) : 0))) {
                throw new Error("Number of sourcemap files should be same as js files.");
            }

            let sourceMapCode: string | null; // eslint-disable-line no-restricted-syntax
            if ((options.noEmitOnError && result.diagnostics.length !== 0) || result.maps.size === 0) {
                // We need to return null here or the runBaseLine will actually create a empty file.
                // Baselining isn't required here because there is no output.
                sourceMapCode = null; // eslint-disable-line no-restricted-syntax
            }
            else {
                sourceMapCode = "";
                result.maps.forEach(sourceMap => {
                    if (sourceMapCode) sourceMapCode += "\r\n";

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Confirm whether declaration maps are intended — if so, enable them so declMaps is true and the check is skipped.
  2. If declaration maps are not intended but separate maps appear, investigate the compiler's sourcemap emit path for a regression.
  3. Inspect result.maps to see which files produced unexpected external maps.

Example fix

// before — inline JS maps but external decl maps without enabling them
// @inlineSourceMap: true
// @declaration: true
// after — also enable declaration maps so external .d.ts.map is expected
// @inlineSourceMap: true
// @declaration: true
// @declarationMap: true
Defensive patterns

Strategy: validation

Validate before calling

if (options.inlineSourceMap && !ts.getAreDeclarationMapsEnabled(options)) {
    if (result.maps.size > 0) throw new Error("External maps produced under inlineSourceMap");
}

Prevention

When it happens

Trigger: A test sets inlineSourceMap:true (without declaration maps) and the compiler emits one or more entries into result.maps. The check is result.maps.size > 0 && !declMaps.

Common situations: A compiler regression that writes separate maps despite inlineSourceMap, or a test/plugin that forces external sourcemaps. Declaration maps are the exception: when getAreDeclarationMapsEnabled is true, external .d.ts.map files are expected even with inline JS sourcemaps.

Related errors


AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12). Data as JSON: /api/errors/1ba5ddbb6fe565f0. Report an issue: GitHub.