From 55c8508db9371e549b4fed0a646fd95acb90730f Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Tue, 4 Aug 2026 12:15:02 +0800 Subject: [PATCH 1/3] fix: pin en-US locale in builtin MDN type links --- .changeset/mdn-type-link-locale.md | 9 +++++++++ .../src/generators/metadata/maps/builtin.json | 20 +++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 .changeset/mdn-type-link-locale.md diff --git a/.changeset/mdn-type-link-locale.md b/.changeset/mdn-type-link-locale.md new file mode 100644 index 00000000..eb0bdff9 --- /dev/null +++ b/.changeset/mdn-type-link-locale.md @@ -0,0 +1,9 @@ +--- +'@node-core/doc-kit': patch +--- + +Pin the `en-US` locale on builtin MDN type links that carry a hash fragment +(e.g. `number`, `string`, `any`). Locale-less MDN URLs redirect to the +visitor's preferred language, where heading anchor IDs are translated, so the +original fragment (e.g. `#number_type`) no longer matched and the link failed +to jump to the target section. diff --git a/packages/core/src/generators/metadata/maps/builtin.json b/packages/core/src/generators/metadata/maps/builtin.json index 5601f242..3823ed48 100644 --- a/packages/core/src/generators/metadata/maps/builtin.json +++ b/packages/core/src/generators/metadata/maps/builtin.json @@ -1,16 +1,16 @@ { "asynciterable": "https://tc39.github.io/ecma262/#sec-asynciterable-interface", - "iterable": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol", + "iterable": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol", "void": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/void", "module namespace object": "https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects", - "null": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#null_type", - "undefined": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#undefined_type", - "boolean": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#boolean_type", - "number": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type", - "bigint": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#bigint_type", - "string": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type", - "symbol": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#symbol_type", - "integer": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type", - "any": "https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#Data_types", + "null": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type", + "undefined": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type", + "boolean": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type", + "number": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type", + "bigint": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type", + "string": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type", + "symbol": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#symbol_type", + "integer": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type", + "any": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types", "this": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/this" } From 5dd3504033a32978fce31a7b6d26878dc2bf8630 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Tue, 4 Aug 2026 12:20:32 +0800 Subject: [PATCH 2/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .changeset/mdn-type-link-locale.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/mdn-type-link-locale.md b/.changeset/mdn-type-link-locale.md index eb0bdff9..df9bc1ac 100644 --- a/.changeset/mdn-type-link-locale.md +++ b/.changeset/mdn-type-link-locale.md @@ -5,5 +5,5 @@ Pin the `en-US` locale on builtin MDN type links that carry a hash fragment (e.g. `number`, `string`, `any`). Locale-less MDN URLs redirect to the visitor's preferred language, where heading anchor IDs are translated, so the -original fragment (e.g. `#number_type`) no longer matched and the link failed -to jump to the target section. +original fragment (e.g. `#number_type`) no longer matches any anchor and the +link fails to jump to the target section. From 81a7c1686cff2e21154adea614ae868a688314a0 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Tue, 4 Aug 2026 12:24:24 +0800 Subject: [PATCH 3/3] fix: update --- .changeset/mdn-type-link-locale.md | 4 ++-- .../generators/metadata/utils/__tests__/resolveTypes.test.mjs | 4 ++-- .../generators/metadata/utils/__tests__/transformers.test.mjs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.changeset/mdn-type-link-locale.md b/.changeset/mdn-type-link-locale.md index df9bc1ac..24e65722 100644 --- a/.changeset/mdn-type-link-locale.md +++ b/.changeset/mdn-type-link-locale.md @@ -5,5 +5,5 @@ Pin the `en-US` locale on builtin MDN type links that carry a hash fragment (e.g. `number`, `string`, `any`). Locale-less MDN URLs redirect to the visitor's preferred language, where heading anchor IDs are translated, so the -original fragment (e.g. `#number_type`) no longer matches any anchor and the -link fails to jump to the target section. +original fragment (e.g. `#number_type`) no longer matches any anchor on the +redirected page and the link fails to jump to the target section. diff --git a/packages/core/src/generators/metadata/utils/__tests__/resolveTypes.test.mjs b/packages/core/src/generators/metadata/utils/__tests__/resolveTypes.test.mjs index bd25c4ac..3832e124 100644 --- a/packages/core/src/generators/metadata/utils/__tests__/resolveTypes.test.mjs +++ b/packages/core/src/generators/metadata/utils/__tests__/resolveTypes.test.mjs @@ -125,7 +125,7 @@ describe('resolveTypeAnnotations', () => { ], [ 'string', - 'https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type', + 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type', ], ['Buffer', 'buffer.html#buffer'], ] @@ -135,7 +135,7 @@ describe('resolveTypeAnnotations', () => { it('resolves every annotation in a nested tree', () => { const STRING_URL = - 'https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type'; + 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type'; // Two per paragraph: a visitor that skips siblings still reaches the first const nodes = ['string', 'HTTP/2 Headers Object', 'string', 'string'].map( diff --git a/packages/core/src/generators/metadata/utils/__tests__/transformers.test.mjs b/packages/core/src/generators/metadata/utils/__tests__/transformers.test.mjs index b6c3355d..1b9e95e5 100644 --- a/packages/core/src/generators/metadata/utils/__tests__/transformers.test.mjs +++ b/packages/core/src/generators/metadata/utils/__tests__/transformers.test.mjs @@ -11,7 +11,7 @@ describe('lookupTypeName', () => { it('resolves JavaScript primitives from the built-in map', () => { strictEqual( lookupTypeName('string'), - 'https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type' + 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type' ); });