Merge pull request #19552 from ajafff/parse-negative-numbers
convertToObject: handle negative numbers in JSON
This commit is contained in:
commit
5d469cf0e8
|
@ -1138,6 +1138,13 @@ namespace ts {
|
|||
reportInvalidOptionValue(option && option.type !== "number");
|
||||
return Number((<NumericLiteral>valueExpression).text);
|
||||
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
if ((<PrefixUnaryExpression>valueExpression).operator !== SyntaxKind.MinusToken || (<PrefixUnaryExpression>valueExpression).operand.kind !== SyntaxKind.NumericLiteral) {
|
||||
break; // not valid JSON syntax
|
||||
}
|
||||
reportInvalidOptionValue(option && option.type !== "number");
|
||||
return -Number((<NumericLiteral>(<PrefixUnaryExpression>valueExpression).operand).text);
|
||||
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
reportInvalidOptionValue(option && option.type !== "object");
|
||||
const objectLiteralExpression = <ObjectLiteralExpression>valueExpression;
|
||||
|
|
|
@ -421,6 +421,24 @@ namespace ts {
|
|||
);
|
||||
});
|
||||
|
||||
it("Convert negative numbers in tsconfig.json ", () => {
|
||||
assertCompilerOptions(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"maxNodeModuleJsDepth": -1
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
compilerOptions: {
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: -1
|
||||
},
|
||||
errors: []
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// jsconfig.json
|
||||
it("Convert correctly format jsconfig.json to compiler-options ", () => {
|
||||
assertCompilerOptions(
|
||||
|
|
Loading…
Reference in a new issue