From 70341aa63d0c07279226012d9846c544f53a4c17 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Aug 2025 10:08:58 +0000 Subject: [PATCH 1/2] fix(deps): update devdependency typescript to ^5.9.2 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3bf49afa..167397fb 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "size-limit": "^11.2.0", "source-map-support": "^0.5.21", "tempy": "^3.1.0", - "typescript": "^5.3.3", + "typescript": "^5.9.2", "typescript-eslint": "^8.39.0", "vitest": "^1.6.1", "vscode-jsonrpc": "^8.2.1", diff --git a/yarn.lock b/yarn.lock index b209ce94..0090fccc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2392,10 +2392,10 @@ typescript-eslint@^8.39.0: "@typescript-eslint/typescript-estree" "8.39.0" "@typescript-eslint/utils" "8.39.0" -typescript@^5.3.3: - version "5.3.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" - integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw== +typescript@^5.9.2: + version "5.9.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.2.tgz#d93450cddec5154a2d5cabe3b8102b83316fb2a6" + integrity sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A== ufo@^1.5.4: version "1.6.1" From 4797f4d781b4705db5fdf6a8cde86dadefeeb6dd Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Tue, 5 Aug 2025 12:45:24 +0200 Subject: [PATCH 2/2] sync with upstream --- docs/configuration.md | 16 ++++-- src/features/fileConfigurationManager.ts | 6 +- src/features/inlay-hints.ts | 3 + src/lsp-server.test.ts | 2 +- src/ts-protocol.ts | 73 +++++++++++++++--------- src/tsServer/server.ts | 2 +- src/utils/api.ts | 1 + src/utils/tsconfig.ts | 6 +- 8 files changed, 72 insertions(+), 37 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 3b816123..bae97804 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -54,6 +54,8 @@ Specifies preferences for the internal `tsserver` process. Those options depend **autoImportFileExcludePatterns** [array of strings] Glob patterns of files to exclude from auto imports. Relative paths are resolved relative to the workspace root. Since TypeScript 4.8.2+. **Default**: `[]` +**autoImportSpecifierExcludeRegexes** [array of strings] Regexp patterns of files to exclude from auto imports. **Default**: `[]` + **disableSuggestions** [boolean] **Default**: `false` **quotePreference** [string] Supported values `'auto'`, `'double'`, `'single'`. **Default**: `'auto'` @@ -84,17 +86,23 @@ Specifies preferences for the internal `tsserver` process. Those options depend **lazyConfiguredProjectsFromExternalProject** [boolean] **Default**: `false` +**maximumHoverLength** [number] A positive integer indicating the maximum length of a hover text before it is truncated. **Default**: `500` + **organizeImportsIgnoreCase** [string or boolean] Indicates whether imports should be organized in a case-insensitive manner. Supported values: `'auto'`, `boolean`. **Default**: `'auto'` - **organizeImportsCollation** [string] Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value of their code points, or via "unicode" collation (via the [Unicode Collation Algorithm](https://unicode.org/reports/tr10/#Scope)) using rules associated with the locale specified in [organizeImportsCollationLocale](#organizeImportsCollationLocale). Supported values: `'ordinal'`, `'unicode'`. **Default**: `'ordinal'` + **organizeImportsCollation** [string] Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value of their code points, or via "unicode" collation (via the [Unicode Collation Algorithm](https://unicode.org/reports/tr10/#Scope)) using rules associated with the locale specified in [organizeImportsLocale](#organizeImportsLocale). Supported values: `'ordinal'`, `'unicode'`. **Default**: `'ordinal'` - **organizeImportsCollationLocale** [string] Indicates the locale to use for "unicode" collation. If not specified, the locale `"en"` is used as an invariant for the sake of consistent sorting. Use `"auto"` to use the detected UI locale. This preference is ignored if [organizeImportsCollation](#organizeImportsNumericCollation) is not `"unicode"`. **Default**: `'en'` + **organizeImportsLocale** [string] Indicates the locale to use for "unicode" collation. If not specified, the locale `"en"` is used as an invariant for the sake of consistent sorting. Use `"auto"` to use the detected UI locale. This preference is ignored if [organizeImportsCollation](#organizeImportsNumericCollation) is not `"unicode"`. **Default**: `'en'` **organizeImportsNumericCollation** [boolean] Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`. This preference is ignored if [organizeImportsCollation](#organizeImportsCollation) is not `"unicode"`. **Default**: `false` -**organizeImportsAccentCollation** [boolean] Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified in [organizeImportsCollationLocale](#organizeImportsCollationLocale). This preference is ignored if [organizeImportsCollation](#organizeImportsCollation) is not `"unicode"`. **Default**: `true` +**organizeImportsAccentCollation** [boolean] Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified in [organizeImportsLocale](#organizeImportsLocale). This preference is ignored if [organizeImportsCollation](#organizeImportsCollation) is not `"unicode"`. **Default**: `true` + +**organizeImportsCaseFirst** [string or boolean] Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale specified in [organizeImportsLocale](#organizeImportsLocale) is used. This preference is ignored if [organizeImportsCollation](#organizeImportsCollation) is not `"unicode"`. This preference is also ignored if we are using case-insensitive sorting, which occurs when [organizeImportsIgnoreCase](#organizeImportsIgnoreCase) is `true`, or if [organizeImportsIgnoreCase](#organizeImportsIgnoreCase) is `"auto"` and the auto-detected case sensitivity is determined to be case-insensitive. Supported values: `'upper'`, `'lower'`, `false`. **Default**: `false` + +**organizeImportsTypeOrder** ["last" | "inline" | "first"] Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is type-only. **Default**: `"last"` -**organizeImportsCaseFirst** [string or boolean] Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale specified in [organizeImportsCollationLocale](#organizeImportsCollationLocale) is used. This preference is ignored if [organizeImportsCollation](#organizeImportsCollation) is not `"unicode"`. This preference is also ignored if we are using case-insensitive sorting, which occurs when [organizeImportsIgnoreCase](#organizeImportsIgnoreCase) is `true`, or if [organizeImportsIgnoreCase](#organizeImportsIgnoreCase) is `"auto"` and the auto-detected case sensitivity is determined to be case-insensitive. Supported values: `'upper'`, `'lower'`, `false`. **Default**: `false` +**preferTypeOnlyAutoImports** [boolean] **Default**: `false` **providePrefixAndSuffixTextForRename** [boolean] **Default**: `true` diff --git a/src/features/fileConfigurationManager.ts b/src/features/fileConfigurationManager.ts index 9d6257ea..92d7f15a 100644 --- a/src/features/fileConfigurationManager.ts +++ b/src/features/fileConfigurationManager.ts @@ -27,6 +27,7 @@ const DEFAULT_TSSERVER_PREFERENCES: Required allowRenameOfImportPath: true, allowTextChangesInNewFiles: true, autoImportFileExcludePatterns: [], + autoImportSpecifierExcludeRegexes: [], disableLineTextInReferences: true, disableSuggestions: false, displayPartsForJSDoc: true, @@ -53,12 +54,15 @@ const DEFAULT_TSSERVER_PREFERENCES: Required interactiveInlayHints: true, jsxAttributeCompletionStyle: 'auto', lazyConfiguredProjectsFromExternalProject: false, + maximumHoverLength: 500, organizeImportsAccentCollation: true, organizeImportsCaseFirst: false, organizeImportsCollation: 'ordinal', - organizeImportsCollationLocale: 'en', + organizeImportsLocale: 'en', organizeImportsIgnoreCase: 'auto', organizeImportsNumericCollation: false, + organizeImportsTypeOrder: 'last', + preferTypeOnlyAutoImports: false, providePrefixAndSuffixTextForRename: true, provideRefactorNotApplicableReason: true, quotePreference: 'auto', diff --git a/src/features/inlay-hints.ts b/src/features/inlay-hints.ts index 9aa47d66..f3e2f19f 100644 --- a/src/features/inlay-hints.ts +++ b/src/features/inlay-hints.ts @@ -109,8 +109,11 @@ function areInlayHintsEnabledForFile(fileConfigurationManager: FileConfiguration function fromProtocolInlayHintKind(kind: ts.server.protocol.InlayHintKind): lsp.InlayHintKind | undefined { switch (kind) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison case 'Parameter': return lsp.InlayHintKind.Parameter; + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison case 'Type': return lsp.InlayHintKind.Type; + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison case 'Enum': return undefined; default: return undefined; } diff --git a/src/lsp-server.test.ts b/src/lsp-server.test.ts index b5458b7f..fb726d98 100644 --- a/src/lsp-server.test.ts +++ b/src/lsp-server.test.ts @@ -1583,7 +1583,7 @@ accessSync('t');`, edits: [ { // Prefers import that is declared in package.json. - newText: 'import { existsSync } from "fs-extra";\n\n', + newText: 'import { existsSync } from "fs";\n\n', range: { end: { character: 0, diff --git a/src/ts-protocol.ts b/src/ts-protocol.ts index 42c52cc6..696b03b3 100644 --- a/src/ts-protocol.ts +++ b/src/ts-protocol.ts @@ -107,27 +107,43 @@ export enum HighlightSpanKind { } export enum JsxEmit { - None = 'None', - Preserve = 'Preserve', - ReactNative = 'ReactNative', - React = 'React' + None = 'none', + Preserve = 'preserve', + ReactNative = 'react-native', + React = 'react', + ReactJSX = 'react-jsx', + ReactJSXDev = 'react-jsxdev', } export enum ModuleKind { - None = 'None', - CommonJS = 'CommonJS', - AMD = 'AMD', - UMD = 'UMD', - System = 'System', - ES6 = 'ES6', - ES2015 = 'ES2015', - ESNext = 'ESNext' + None = 'none', + CommonJS = 'commonjs', + AMD = 'amd', + UMD = 'umd', + System = 'system', + ES6 = 'es6', + ES2015 = 'es2015', + ES2020 = 'es2020', + ES2022 = 'es2022', + ESNext = 'esnext', + Node16 = 'node16', + Node18 = 'node18', + Node20 = 'node20', + NodeNext = 'nodenext', + Preserve = 'preserve', } export enum ModuleResolutionKind { - Classic = 'Classic', - Node = 'Node', - // Bundler = 'Bundler' + Classic = 'classic', + /** @deprecated Renamed to `Node10` */ + Node = 'node', + /** @deprecated Renamed to `Node10` */ + // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values + NodeJs = 'node', + Node10 = 'node10', + Node16 = 'node16', + NodeNext = 'nodenext', + Bundler = 'bundler', } export enum SemicolonPreference { @@ -205,18 +221,21 @@ export enum ScriptElementKindModifier { } export enum ScriptTarget { - ES3 = 'ES3', - ES5 = 'ES5', - ES6 = 'ES6', - ES2015 = 'ES2015', - ES2016 = 'ES2016', - ES2017 = 'ES2017', - ES2018 = 'ES2018', - ES2019 = 'ES2019', - ES2020 = 'ES2020', - ES2021 = 'ES2021', - ES2022 = 'ES2022', - ESNext = 'ESNext' + ES3 = 'es3', + ES5 = 'es5', + ES6 = 'es6', + ES2015 = 'es2015', + ES2016 = 'es2016', + ES2017 = 'es2017', + ES2018 = 'es2018', + ES2019 = 'es2019', + ES2020 = 'es2020', + ES2021 = 'es2021', + ES2022 = 'es2022', + ESNext = 'esnext', + JSON = 'json', + // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values + Latest = 'esnext', } export enum SymbolDisplayPartKind { diff --git a/src/tsServer/server.ts b/src/tsServer/server.ts index 0184c73e..6d8405bc 100644 --- a/src/tsServer/server.ts +++ b/src/tsServer/server.ts @@ -378,7 +378,7 @@ class RequestRouter { request .then(result => { requestStates[serverIndex] = RequestState.Resolved; - const erroredRequest = requestStates.find(state => state.type === RequestState.Type.Errored) as RequestState.Errored | undefined; + const erroredRequest = requestStates.find(state => state.type === RequestState.Type.Errored); if (erroredRequest) { // We've gone out of sync this.delegate.onFatalError(command, erroredRequest.err); diff --git a/src/utils/api.ts b/src/utils/api.ts index 85bf822f..871f07ed 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -33,6 +33,7 @@ export default class API { public static readonly v490 = API.fromSimpleString('4.9.0'); public static readonly v500 = API.fromSimpleString('5.0.0'); public static readonly v510 = API.fromSimpleString('5.1.0'); + public static readonly v540 = API.fromSimpleString('5.4.0'); public static fromVersionString(versionString: string): API { let version = semver.valid(versionString); diff --git a/src/utils/tsconfig.ts b/src/utils/tsconfig.ts index f3c9b433..73af8f8c 100644 --- a/src/utils/tsconfig.ts +++ b/src/utils/tsconfig.ts @@ -19,10 +19,10 @@ export function getInferredProjectCompilerOptions( workspaceConfig: WorkspaceConfigurationImplicitProjectConfigurationOptions, ): ts.server.protocol.ExternalProjectCompilerOptions { const projectConfig: ts.server.protocol.ExternalProjectCompilerOptions = { - module: ModuleKind.ESNext, - moduleResolution: ModuleResolutionKind.Node, + module: version.gte(API.v540) ? ModuleKind.Preserve : ModuleKind.ESNext, + moduleResolution: version.gte(API.v540) ? ModuleResolutionKind.Bundler : ModuleResolutionKind.Node, target: ScriptTarget.ES2022, - jsx: JsxEmit.React, + jsx: JsxEmit.ReactJSX, }; if (version.gte(API.v500)) {