Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 8 additions & 56 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/yn-npm-2.0.0-3ad11617c1-9d49527cb3.zip
Binary file not shown.
3 changes: 1 addition & 2 deletions packages/js-dash-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "yarn run test:types && yarn run test:unit && yarn run test:browsers",
"test:browsers": "karma start ./karma/karma.conf.js --single-run",
"test:browsers:functional": "LOAD_ENV=true karma start ./karma/karma.functional.conf.js --single-run",
"test:unit": "ts-mocha -p tsconfig.mocha.json src/**/*.spec.ts",
"test:unit": "tsc -p tsconfig.mocha.json && mocha build/**/*.spec.js",
"test:functional": "yarn run build:ts && LOAD_ENV=true mocha --recursive tests/functional/**/*.js",
"test:types": "yarn pnpify tsd",
"prepublishOnly": "yarn run build",
Expand Down Expand Up @@ -100,7 +100,6 @@
"terser-webpack-plugin": "^5.3.11",
"tls": "^0.0.1",
"ts-loader": "^9.5.0",
"ts-mocha": "^10.0.0",
"ts-mock-imports": "^1.3.0",
"ts-node": "^10.4.0",
"tsd": "^0.28.1",
Expand Down
1 change: 0 additions & 1 deletion packages/js-dash-sdk/tests/functional/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('SDK', function suite() {
},
},
};

clientInstance = new Dash.Client(clientOpts);
});

Expand Down
8 changes: 4 additions & 4 deletions packages/js-dash-sdk/tsconfig.mocha.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es6",
"skipLibCheck": true,
"esModuleInterop": true,
"outDir": "./build",
Comment on lines +5 to +7
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

JSON Formatting: Remove Trailing Comma in compilerOptions.

The additions of "skipLibCheck", "esModuleInterop", and "outDir" are beneficial for optimizing type-checking and module interoperability, and for directing output during compilation. However, please note that valid JSON does not allow a trailing comma in an object. The comma after "outDir": "./build" (line 7) should be removed to avoid JSON parsing errors.

-    "outDir": "./build",
+    "outDir": "./build"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"skipLibCheck": true,
"esModuleInterop": true,
"outDir": "./build",
"skipLibCheck": true,
"esModuleInterop": true,
"outDir": "./build"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a JSON 5 because tsc parses it successfully.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

@shumkov You're absolutely right! TypeScript's configuration files (tsconfig.json) support JSON5 format, which allows trailing commas, comments, and other convenient features. The current syntax is perfectly valid.


🌐 Web query:

Does TypeScript support JSON5 in tsconfig.json files?

💡 Result:

TypeScript's tsconfig.json files do not natively support full JSON5 syntax, but they do support a subset of JSON5 features through JSON with Comments (JSONC)[1][5][8]. Here's a breakdown:

Key Details

  1. Supported Syntax:

    • Comments (// and /* */)[2][8]
    • Trailing commas[3][8]
    • Single-quoted strings are not supported[10]
  2. Limitations:

    • Unquoted object keys and other advanced JSON5 features won't work[4][9]
    • TypeScript explicitly treats tsconfig.json as JSONC (JSON with Comments), not full JSON5[5]

Implementation Notes

  • The TypeScript compiler (tsc) uses a parser that allows:

    {
      // This comment works
      "compilerOptions": {
        "target": "ES2022",  // Trailing comma allowed
      },                      // Another trailing comma
    }

    [2][3][8]

  • Attempting to use unsupported JSON5 features like unquoted keys:

    {
      unquotedKey: "value" // Syntax error
    }

    will fail compilation[4][9].

Workarounds

For full JSON5 support in configs:

  1. Use tools like json5 to parse .json5 files[1][4]
  2. Configure build tools to transform JSON5 → JSON during compilation[1]

Why This Matters

While tsconfig.json allows limited JSON5-like syntax for readability[2][8], developers needing advanced features must use external tooling or alternative config formats[1][4]. The distinction between JSONC and JSON5 is subtle but impacts compatibility[4][9].

Citations:


@shumkov I need to correct my previous statement. TypeScript actually uses JSONC (JSON with Comments) format for tsconfig files, not full JSON5. JSONC supports a subset of JSON5-like features, specifically comments and trailing commas, which explains why the trailing comma works in your configuration. The current syntax is indeed valid with JSONC.


✏️ Learnings added
Learnt from: shumkov
PR: dashpay/platform#2475
File: packages/js-dash-sdk/tsconfig.mocha.json:5-7
Timestamp: 2025-02-19T14:58:40.145Z
Learning: TypeScript configuration files (tsconfig.json) support JSON5 format, which allows trailing commas and comments. The TypeScript compiler (tsc) successfully parses these JSON5 features.

Learnt from: shumkov
PR: dashpay/platform#2475
File: packages/js-dash-sdk/tsconfig.mocha.json:5-7
Timestamp: 2025-02-19T14:58:40.145Z
Learning: TypeScript configuration files (tsconfig.json) use JSONC (JSON with Comments) format, which supports comments and trailing commas, but not full JSON5 features. The TypeScript compiler (tsc) successfully parses these JSONC features.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

},
"include": [
"src/**/*",
],
"exclude": []
"include": ["src/**/*.spec.ts", "src/test/**/*.ts"],
}
86 changes: 37 additions & 49 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4507,7 +4507,7 @@ __metadata:
languageName: node
linkType: hard

"arrify@npm:^1.0.0, arrify@npm:^1.0.1":
"arrify@npm:^1.0.1":
version: 1.0.1
resolution: "arrify@npm:1.0.1"
checksum: 745075dd4a4624ff0225c331dacb99be501a515d39bcb7c84d24660314a6ec28e68131b137e6f7e16318170842ce97538cd298fc4cd6b2cc798e0b957f2747e7
Expand Down Expand Up @@ -5056,7 +5056,7 @@ __metadata:
languageName: node
linkType: hard

"buffer-from@npm:^1.0.0, buffer-from@npm:^1.1.0":
"buffer-from@npm:^1.0.0":
version: 1.1.2
resolution: "buffer-from@npm:1.1.2"
checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb
Expand Down Expand Up @@ -6439,7 +6439,6 @@ __metadata:
terser-webpack-plugin: "npm:^5.3.11"
tls: "npm:^0.0.1"
ts-loader: "npm:^9.5.0"
ts-mocha: "npm:^10.0.0"
ts-mock-imports: "npm:^1.3.0"
ts-node: "npm:^10.4.0"
tsd: "npm:^0.28.1"
Expand Down Expand Up @@ -6794,13 +6793,6 @@ __metadata:
languageName: node
linkType: hard

"diff@npm:^3.1.0":
version: 3.5.0
resolution: "diff@npm:3.5.0"
checksum: cfbc2df98d6f8eb82c0f7735c8468695f65189d31f95a708d4c97cd96a8083fdfd83d87a067a29924ae7d8ff64f578e7da78391af537815750268555fe0df9f0
languageName: node
linkType: hard

"diff@npm:^4.0.1":
version: 4.0.2
resolution: "diff@npm:4.0.2"
Expand Down Expand Up @@ -11030,7 +11022,7 @@ __metadata:
languageName: node
linkType: hard

"minimist@npm:^1.1.0, minimist@npm:^1.2.0, minimist@npm:^1.2.3, minimist@npm:^1.2.5, minimist@npm:^1.2.6":
"minimist@npm:^1.1.0, minimist@npm:^1.2.3, minimist@npm:^1.2.5, minimist@npm:^1.2.6":
version: 1.2.6
resolution: "minimist@npm:1.2.6"
checksum: b956a7d48669c5007f0afce100a92d3af18e77939a25b5b4f62e9ea07c2777033608327e14c2af85684d5cd504f623f2a04d30a4a43379d21dd3c6dcf12b8ab8
Expand Down Expand Up @@ -11181,7 +11173,7 @@ __metadata:
languageName: node
linkType: hard

"mkdirp@npm:^0.5.1, mkdirp@npm:^0.5.5":
"mkdirp@npm:^0.5.5":
version: 0.5.6
resolution: "mkdirp@npm:0.5.6"
dependencies:
Expand Down Expand Up @@ -14181,7 +14173,7 @@ __metadata:
languageName: node
linkType: hard

"source-map-support@npm:^0.5.6, source-map-support@npm:~0.5.20":
"source-map-support@npm:~0.5.20":
version: 0.5.21
resolution: "source-map-support@npm:0.5.21"
dependencies:
Expand Down Expand Up @@ -15039,23 +15031,6 @@ __metadata:
languageName: node
linkType: hard

"ts-mocha@npm:^10.0.0":
version: 10.0.0
resolution: "ts-mocha@npm:10.0.0"
dependencies:
ts-node: "npm:7.0.1"
tsconfig-paths: "npm:^3.5.0"
peerDependencies:
mocha: ^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X
dependenciesMeta:
tsconfig-paths:
optional: true
bin:
ts-mocha: bin/ts-mocha
checksum: b11f2a8ceecf195b0db724da429159982fef12e4357088fe900289223587217e8c126ead7929679edd58bf19ad96c5da5911535d26f535386632e18fbff10c40
languageName: node
linkType: hard

"ts-mock-imports@npm:^1.3.0":
version: 1.3.8
resolution: "ts-mock-imports@npm:1.3.8"
Expand All @@ -15066,25 +15041,45 @@ __metadata:
languageName: node
linkType: hard

"ts-node@npm:7.0.1":
version: 7.0.1
resolution: "ts-node@npm:7.0.1"
"ts-node@npm:^10.4.0":
version: 10.9.2
resolution: "ts-node@npm:10.9.2"
dependencies:
arrify: "npm:^1.0.0"
buffer-from: "npm:^1.1.0"
diff: "npm:^3.1.0"
"@cspotcode/source-map-support": "npm:^0.8.0"
"@tsconfig/node10": "npm:^1.0.7"
"@tsconfig/node12": "npm:^1.0.7"
"@tsconfig/node14": "npm:^1.0.0"
"@tsconfig/node16": "npm:^1.0.2"
acorn: "npm:^8.4.1"
acorn-walk: "npm:^8.1.1"
arg: "npm:^4.1.0"
create-require: "npm:^1.1.0"
diff: "npm:^4.0.1"
make-error: "npm:^1.1.1"
minimist: "npm:^1.2.0"
mkdirp: "npm:^0.5.1"
source-map-support: "npm:^0.5.6"
yn: "npm:^2.0.0"
v8-compile-cache-lib: "npm:^3.0.1"
yn: "npm:3.1.1"
peerDependencies:
"@swc/core": ">=1.2.50"
"@swc/wasm": ">=1.2.50"
"@types/node": "*"
typescript: ">=2.7"
peerDependenciesMeta:
"@swc/core":
optional: true
"@swc/wasm":
optional: true
bin:
ts-node: dist/bin.js
checksum: c1e0f1582867c34a03a25b1861e86922b9576931d473d48cd13275400832972350c4564e5f2c2df5817be6acbbb8e1dedf43bdd6f8c0f06b15d3530562a08a90
ts-node-cwd: dist/bin-cwd.js
ts-node-esm: dist/bin-esm.js
ts-node-script: dist/bin-script.js
ts-node-transpile-only: dist/bin-transpile.js
ts-script: dist/bin-script-deprecated.js
checksum: a91a15b3c9f76ac462f006fa88b6bfa528130dcfb849dd7ef7f9d640832ab681e235b8a2bc58ecde42f72851cc1d5d4e22c901b0c11aa51001ea1d395074b794
languageName: node
linkType: hard

"ts-node@npm:^10.4.0, ts-node@npm:^10.9.1":
"ts-node@npm:^10.9.1":
version: 10.9.1
resolution: "ts-node@npm:10.9.1"
dependencies:
Expand Down Expand Up @@ -16395,13 +16390,6 @@ __metadata:
languageName: node
linkType: hard

"yn@npm:^2.0.0":
version: 2.0.0
resolution: "yn@npm:2.0.0"
checksum: 9d49527cb3e9a0948cc057223810bf30607bf04b9ff7666cc1681a6501d660b60d90000c16f9e29311b0f28d8a06222ada565ccdca5f1049cdfefb1908217572
languageName: node
linkType: hard

"yocto-queue@npm:^0.1.0":
version: 0.1.0
resolution: "yocto-queue@npm:0.1.0"
Expand Down