-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.9.1
Search Terms:
JSON
resolveJsonModule
json trailing comma
Code
import * as ts from 'typescript';
console.log(ts.version);
const output = ts.transpileModule(
`
{"foo": 123,} // note trailing comma
`,
{
fileName: 'foo.json',
compilerOptions: {
resolveJsonModule: true,
removeComments: true
},
reportDiagnostics: true
}
);
console.dir(output.diagnostics); // no errors
console.dir(output.outputText); // '{ "foo": 123, }\r\n' still has trailing comma
Expected behavior:
Emitted JSON does not have trailing comma: { "foo": 123 }
...or compiler emits a diagnostic to tell me the trailing comma is not allowed in input json.
Actual behavior:
Emitted JSON has trailing comma: { "foo": 123, }
and no diagnostics are reported.
Playground Link:
N/A because Playground assumes .ts file extension.
Related Issues:
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue