-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flag 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5 #8650
Comments
Weird, I have the latest VSCode with TypeScript 4.9.4 (same as your version, according to your |
Likely because OP is using the beta version of TS 5.0, where that flag is introduced. |
@gornostay25 If you right click the bottom right corner (next to where it says |
I guess another thing is to add said That flag is still available until 5.5, which is more than one year from now. I suspect we have SvelteKit 2.0 by then at which point we can switch flags. |
Related: microsoft/TypeScript#52203 |
For me error was removed after disabling the JavaScript and TypeScript Nightly extension in VS Code. But yeah you could probably also change the TS-version in your workspace. |
Related to #8650 Co-authored-by: Rich Harris <[email protected]>
The TS 5 beta introduced a few deprecation flags that sveltekit relies on, It would be really great for sveltekit to aim to support TS 5 as soon as a stable release ships in march for that reason alone, I (and I imagine most monorepo projects) have had to totally ignore sveltekit's awesome generated types until now |
AFAIK we're dependent on Esbuild and Vite supporting those first since it affects how they transpile the code, so they need to support it first. Since our peer dependency is on a Vite version lower than the one that will support it, we also need additional checks to stay backwards compatible, else it's a breaking change. |
That makes sense, and I also just stumbled upon the |
The |
this helped! |
But your vs code is very likely using typescript 5.0, which is why you get the warning. Either tell vs code to use the workspace typescript version or upgrade to 5.0, or add the ignoreDeprecations flag as the warning suggests. Either of those will silence it |
As a band-aid fix, you can ignore deprecation warnings if you're getting this error: {
"compilerOptions": {
"ignoreDeprecations": "5.0",
}
} Of course, ignore deprecation warnings at your own risk. |
Here's the ESBuild issue that tracks adding the |
This comment was marked as off-topic.
This comment was marked as off-topic.
I made a python script that gets rid of the error, in the meantime. It's very simplistic, but it does the job. As written, the python script sits in the project root python script#!/bin/env python
from pathlib import Path
import re
import time
dir = Path(__file__).resolve().parent
file = dir / '.svelte-kit/tsconfig.json'
patterns = [
r'^\s+"importsNotUsedAsValues".+$\n',
r'^\s+"preserveValueImports".+$\n',
]
def loop():
while True:
check_and_remove()
time.sleep(60)
def check_and_remove():
text = file.read_text()
if _check(text):
_remove(text)
print('Removed bad values')
else:
print('Bad values not found')
def _remove(text):
for p in patterns:
text = re.sub(p, '', text, flags=re.MULTILINE)
file.write_text(text)
def _check(text):
return any([
re.search(p, text, flags=re.MULTILINE)
for p in patterns
])
if __name__ == '__main__':
loop() And the set up a background task in vscode to automatically run the script tasks.json{
"version": "2.0.0",
"tasks": [
{
"label": "Fix tsconfig",
"type": "process",
"command": "./stupid_error.py",
"isBackground": true,
"runOptions": {
"runOn": "folderOpen"
},
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
}
]
} @ivanhofer Edit: actually, now that I've actually read your reply, that is a much slicker fix |
@cmidkiff87 looks like a bad hack. There is an option to alter the In one of my projects this looks like this: import adapter from '@sveltejs/adapter-auto'
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
typescript: {
config: (tsconfig) => {
const {
// destructure properties we don't want
importsNotUsedAsValues: _,
preserveValueImports: __,
// keep the rest in a single object
...compilerOptions
} = tsconfig.compilerOptions
return {
...tsconfig,
compilerOptions: {
...compilerOptions,
},
}
},
},
},
}
export default config Note: I have removed my project specific configs, but haven't tested it out with the exact config as above. Maybe you need to slighlty adjust it. |
typescript value on import adapter from '@sveltejs/adapter-static';
import preprocess from 'svelte-preprocess';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess({ postcss: true }),
kit: {
//trailingSlash: 'always',
typescript: {
config: (tsconfig) => {
const {
//destructure properties we don't want
importsNotUsedAsValues: _,
preserveValueImports: __,
//keep the rest in a single object
...compilerOptions
} = tsconfig.compilerOptions
return {
...tsconfig,
compilerOptions: {
...compilerOptions,
},
}
},
},
}
};
export default config;
|
@nickmura maybe try to upgrade to the latest |
that’s a great idea
…On Tue, Jun 20, 2023 at 12:19 PM Hofer Ivan ***@***.***> wrote:
@nickmura <https://github.com/nickmura> maybe try to upgrade to the
latest SvelteKit version.
—
Reply to this email directly, view it on GitHub
<#8650 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWCHILWTSAFVNCE6VJFXU7TXMHST3ANCNFSM6AAAAAAUCPPSGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Using the 'workspace' typescript version is just a workaround, and this needs to be changed on the Svelte side I believe. |
@temeddix do you know what the fix is? I wasn't using Svelte so I could implement and verify locally. The VSCode package update I mentioned above only helped for a bit, I'm back to seeing this warning now. |
What is this error aboutThis is a deprecation warning from Typescript (not SvelteKit or anything else). Certain settings are deprecated but they will continue to work until TypeScript version 5.5. We can't update them without this being a breaking change so we'll do that in SvelteKit 2.0. The error is a bit confusing because it can come from both your VS Code installation (if you use one that has TypeScript 5.0 or higher bundled with it) and/or your SvelteKit project. How to fix itYou have two options: Option 1: Update packagesUpdate your
Then install and afterwards rerun Option 2: Use TS workspace versionIf you're using a TypeScript version lower than 5 in your project and don't want to update for some reason, then tell VS Code to use the workspace version of TypeScript. |
@dummdidumm do you already know what the breaking change needs to be? That is what I was trying to ask, what do I need to change in the code so that I am no longer using the deprecated setting? Allowing deprecated settings seems like just a workaround, especially if it won't continue past TS 5.5. I switched to "import type" for everything that isn't explicitly used per TS1371. I added "verbatimModuleSyntax" to tsconfig as per the error message. I never had importsNotUsedAsValues set, so I didn't need to remove it for TS5101. EDIT: Dang it. It took digging back to that screenshot to see the "extends", plasmo is setting importsNotUsedAsValues so it's their fault. Is there a way for me to override and reset that setting? Otherwise I'd have to copy/paste the rest of their file and remove the extends to drop that setting right? |
Unfortunately there is no way that I know of to reset a config to nothing. |
- ignore the warning since svelte still needs the current flag - issue: github.com/sveltejs/kit/issues/8650
Added to esbuild in 0.18: https://github.com/evanw/esbuild/blob/main/CHANGELOG.md#0180 |
Done here: e3d6b99 I accidentally pushed it to the |
Just a note that after upgrading to TS 5.5, we needed to set In case anybody else encounters this issue |
That's expected because starting with TS5.5 the old options cease to function (they do nothing anymore) |
indeed upgrading |
READ HERE HOW TO FIX IT
#8650 (comment)
Bug report
Describe the bug
My VScode show this in problems tab
.svelte-kit/tsconfig.json
Reproduction
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: