From fb7080f82d51aa7e2e86041a50966d9e74d1c595 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Sat, 30 Oct 2021 20:56:12 +0900 Subject: [PATCH] Handle TypeScript 4.5 new file extensions `.mts` and `.cts` (#11721) * Handle .mts and .cts * Update integration tests * Add changelog --- changelog_unreleased/typescript/11721.md | 7 +++++++ src/language-js/index.js | 14 +++++++++----- .../__tests__/__snapshots__/support-info.js.snap | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 changelog_unreleased/typescript/11721.md diff --git a/changelog_unreleased/typescript/11721.md b/changelog_unreleased/typescript/11721.md new file mode 100644 index 000000000..12be34ed1 --- /dev/null +++ b/changelog_unreleased/typescript/11721.md @@ -0,0 +1,7 @@ +#### Support TypeScript 4.5 (#11721 by @sosukesuzuki) + +Support new TypeScript 4.5 features. + +##### Handle `.mts` and `.cts` + +Handle new file extensions `.mts` and `.cts`. diff --git a/src/language-js/index.js b/src/language-js/index.js index 9df41d132..ad2c2f0d2 100644 --- a/src/language-js/index.js +++ b/src/language-js/index.js @@ -67,11 +67,15 @@ const languages = [ codemirrorMimeType: "text/jsx", color: undefined, })), - createLanguage(require("linguist-languages/data/TypeScript.json"), () => ({ - since: "1.4.0", - parsers: ["typescript", "babel-ts"], - vscodeLanguageIds: ["typescript"], - })), + createLanguage( + require("linguist-languages/data/TypeScript.json"), + (data) => ({ + since: "1.4.0", + parsers: ["typescript", "babel-ts"], + vscodeLanguageIds: ["typescript"], + extensions: [...data.extensions, ".mts", ".cts"], + }) + ), createLanguage(require("linguist-languages/data/TSX.json"), () => ({ since: "1.4.0", parsers: ["typescript", "babel-ts"], diff --git a/tests/integration/__tests__/__snapshots__/support-info.js.snap b/tests/integration/__tests__/__snapshots__/support-info.js.snap index 6296347e5..0245e7203 100644 --- a/tests/integration/__tests__/__snapshots__/support-info.js.snap +++ b/tests/integration/__tests__/__snapshots__/support-info.js.snap @@ -394,7 +394,7 @@ exports[`CLI --support-info (stdout) 1`] = ` \\"codemirrorMimeType\\": \\"application/typescript\\", \\"codemirrorMode\\": \\"javascript\\", \\"color\\": \\"#2b7489\\", - \\"extensions\\": [\\".ts\\"], + \\"extensions\\": [\\".ts\\", \\".mts\\", \\".cts\\"], \\"interpreters\\": [\\"deno\\", \\"ts-node\\"], \\"linguistLanguageId\\": 378, \\"name\\": \\"TypeScript\\",