Open mjbvz opened 1 month ago
Can confirm, using the typeOrder
setting also doesn't seem to work.
"typescript.preferences.organizeImports": {
"typeOrder": "first"
}
Using this setting, type-only imports are not sorted to be first.
When was this option added? I thought this had to be like: https://github.com/microsoft/TypeScript/blob/460be92510abf07b7fb87e1d2a6649823805e195/.vscode/settings.template.json#L25-L38
@jakebailey The way they are entered into VScode's typescript
settings (aka the non-unstable version) is different. They were added to VSCode over the summer (I think August?).
@grallbring In the meantime while I am investigating why the vscode preferences don't work/fixing this issue, specifying the settings under unstable (as mentioned in Jake's comment) should work, and I believe the unstable settings should override any of the non-working settings.
@iisaduan These unstable settings do not seem to have any effect whatsoever.
"typescript.unstable": {
"typeOrder": "first"
}
Using this setting, type-only imports are mixed with the other imports like before.
VS Code also gives me this hint when using the unstable setting:
I'm using version 1.94.2.
@grallbring The input for the unstable are under different names, since they are directly passed to our preferences
object. For type order first, this is the setting you should include. You'll also need a tsserver version of >5.4.
"typescript.unstable": {
"organizeImportsTypeOrder": "first"
}
(Perhaps I can look into making the vscode names the same. IIRC the reason we didn't do this in the first place was because of how vscode groups settings, but maybe this is not a necessity for organize imports)
@iisaduan I see. I've adjusted the setting:
"typescript.unstable": {
"organizeImportsTypeOrder": "first"
}
However, the issue remains.
Is the tsserver version the same as the typescript version my project uses?
I'm using "typescript": "^5.6.3",
.
Just to make sure - the setting should make it so that the type import is appearing first in this list, correct?
import DefaultLayout from "@/layouts/DefaultLayout";
import IndexPage from "@/pages/IndexPage";
import { MantineProvider } from "@mantine/core";
import "@mantine/core/styles.css";
import type { Router } from "@remix-run/router"; // <-- this one should be first when saving the file, right?
import React from "react";
import ReactDOM from "react-dom/client";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
@grallbring It's supposed to apply to only named imports:
import { type Router, type T, A, b, y, Z } from "@remix-run/router";
The order of declarations are sorted by module specifier, and if there are multiple declarations with different specifiers, then we tie-break by type of import declaration . IIRC, this ordering is to keep compatibility with ESlint and other formatters.
@grallbring The tsserver version, by default, is the one that your project uses, but it is possible to specify a different version using the vscode setting "typescript.tsdk"
https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript
@iisaduan Understood, then I misunderstood the purpose of the setting. Thanks for the detailed explanation!
🔎 Search Terms
🕗 Version & Regression Information
5.6, not a regression
⏯ Playground Link
No response
💻 Code
In VS Code set:
Open a TS file:
Run organize imports
🙁 Actual behavior
No change
🙂 Expected behavior
Should sort imports so upper case comes first?
I confirmed that we send along
"organizeImportsCaseFirst": "upper"
in theconfigure
request for the fileNone of the other organize imports settings seems to work either
Additional information about the issue
No response