Skip to content

refactor: update TypeScript to v6#224

Open
lumirlumir wants to merge 4 commits intomainfrom
refactor/use-typescript-6
Open

refactor: update TypeScript to v6#224
lumirlumir wants to merge 4 commits intomainfrom
refactor/use-typescript-6

Conversation

@lumirlumir
Copy link
Copy Markdown
Member

@lumirlumir lumirlumir commented Mar 25, 2026

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

This PR updates TypeScript to v6.

The following two changes mainly affected us during the upgrade to TypeScript v6.

  • strict mode is now the default.

https://devblogs.microsoft.com/typescript/announcing-typescript-6-0/#simple-default-changes

image
  • rootdir now defaults to .

https://devblogs.microsoft.com/typescript/announcing-typescript-6-0/#rootdir-now-defaults-to-.

image

What changes did you make? (Give an overview)

I've tried to retain strict mode behavior as much as possible and only disabled it where it produced too many errors.

src/index.js

The logic below produced a type error after upgrading to TypeScript v6, so I used an object getter instead to avoid the error and to avoid the block-syntax workaround.

json/src/index.js

Lines 39 to 42 in c9e816f

// eslint-disable-next-line no-lone-blocks -- The block syntax { ... } ensures that TypeScript does not get confused about the type of `plugin`.
{
plugin.configs.recommended.plugins.json = plugin;
}

Freezing the configuration object wasn't considered a breaking change in eslint/eslint#20116, so using a getter here seems fine, but I'd welcome other opinions.

I've also verified that the output index.d.ts file is the same as before.

tests/types/tsconfig.json

  • Re-enabled strictNullChecks and useUnknownInCatchVariables after they were turned off in root level tsconfig.json.

package.json

  • Added @types/natural-compare as a devDependency to fix a type error introduced by the TypeScript v6 breaking change.

tsconfig.json

  • Added "rootDir": "./src" to address the breaking change in TypeScript v6.
  • Turned off strictNullChecks because adopting it would require extensive changes and it was previously disabled.
  • Turned off useUnknownInCatchVariables because adopting it requires some changes and it was previously disabled.

Related Issues

N/A

Is there anything you'd like reviewers to focus on?

N/A

@eslintbot eslintbot added this to Triage Mar 25, 2026
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Mar 25, 2026
@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage Mar 25, 2026
@lumirlumir lumirlumir force-pushed the refactor/use-typescript-6 branch from caa11b5 to 35cda36 Compare March 27, 2026 10:51
@lumirlumir lumirlumir marked this pull request as ready for review March 27, 2026 11:13
Copilot AI review requested due to automatic review settings March 27, 2026 11:13
@lumirlumir lumirlumir moved this from Implementing to Needs Triage in Triage Mar 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the repository’s TypeScript toolchain to v6 and adjusts configuration/type-checking to accommodate TypeScript v6 default behavior changes (notably strict and rootDir defaults), while keeping emitted typings and runtime behavior stable.

Changes:

  • Bumps typescript to ^6.0.2 and adds @types/natural-compare for stricter type-checking.
  • Updates root tsconfig.json to pin rootDir and selectively disable specific strictness flags.
  • Adjusts src/index.js recommended config to reference the plugin via a getter (avoiding TS v6 inference issues) and tightens tests/types/tsconfig.json strictness.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
tsconfig.json Pins rootDir to keep dist/ layout stable under TS v6 and overrides specific strict options.
tests/types/tsconfig.json Re-enables strictNullChecks and useUnknownInCatchVariables for type tests despite root-level overrides.
src/index.js Replaces post-definition assignment with a getter-based plugins.json reference to avoid TS v6 typing issues.
package.json Updates TypeScript to v6 and adds missing ambient types for natural-compare.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

snitin315
snitin315 previously approved these changes Mar 29, 2026
Copy link
Copy Markdown
Contributor

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@snitin315 snitin315 moved this from Needs Triage to Second Review Needed in Triage Mar 29, 2026
@nzakas
Copy link
Copy Markdown
Member

nzakas commented Apr 1, 2026

Practical question: TypeScript v6 just came out, do we need to rush to support it? What happens if someone with TypeScript v6 tries to use a v5 package? Is there any end-user benefit or is this just about upgrading to the latest?

@lumirlumir
Copy link
Copy Markdown
Member Author

lumirlumir commented Apr 2, 2026

Practical question: TypeScript v6 just came out, do we need to rush to support it? What happens if someone with TypeScript v6 tries to use a v5 package? Is there any end-user benefit or is this just about upgrading to the latest?

I first tried upgrading TypeScript to v6 to see whether the deprecation of some options in v6 would affect our use case and end users, since those deprecations might have an impact.

After investigating the codebase and reviewing the TypeScript v6 announcement, my understanding is that our current tsconfig.json setup is not affected by the changes in TypeScript v6. I verified that the generated .d.ts files did not change after upgrading to TypeScript v6 and the .js files only include refactoring and contain no logic changes. (But, I only verified this against the Markdown, JSON, and CSS language plugins, so other repositories may need to be checked.)

In summary, I think updating to TypeScript v6 will not affect end users because the output files remain unchanged. So, as a result, this PR simply upgrades to the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Second Review Needed

Development

Successfully merging this pull request may close these issues.

6 participants