Skip to content

resolveJsonModule conflict with sourceMap #24546

@GlenCFL

Description

@GlenCFL

TypeScript Version: 2.9.1 and 3.0.0-dev.20180531

Search Terms:

JSON
resolveJsonModule
sourceMap

Code

A JSON file at "src/test.json":

{
  "value": 42
}

Both resolveJsonModule and sourceMap enabled within a tsconfig.json file at ./:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "outDir": "./out",
    "lib": [
      "es2016"
    ],
    "sourceMap": true,
    "rootDir": "src",
  },
  "include": [
    "src/**/*.ts"
  ]
}

A TypeScript file at ./src/main.ts that utilizes this JSON file:

import test from "./test.json";

console.log(test.value);

Expected behavior:

  1. The outputted JSON file at ./out/test.json should have the following contents:
{
  "value": 42
}
  1. The source map file at ./out/test.json.map should not exist.

Actual behavior:

  1. The outputted file at ./out/test.json has a comment indicating the source map at the bottom:
{
  "value": 42
}
//# sourceMappingURL=test.json.map
  1. The source map file at ./out/test.json.map exists.

Playground Link: N/A.

Related Issues: #24530 and #24514

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions