3.0.1 incorrectly deleting required imports from typescript files
See original GitHub issueHi,
The 3.0.1 update seems to be incorrectly deleting required imports.
The following code demonstrates the issue:
If I have TypeScript:
import { NormalizedCacheObject } from 'apollo-cache-inmemory'
import AWSAppSyncClient from 'aws-appsync'
export class Foo {
public constructor(private readonly appSyncClient: AWSAppSyncClient<NormalizedCacheObject>) {}
getClient(): any {
return this.appSyncClient
}
}
with package.json
{
"name": "scratch",
"version": "1.0.0",
"main": "index.js",
"license": "UNLICENSED",
"private": true,
"scripts": {
"prettier": "prettier --list-different \"**/*.{json,js,ts,yml,}\""
},
"resolutions": {
"apollo-cache-inmemory": "^1.6.6"
},
"devDependencies": {
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^3.0.1",
"typescript": "^4.7.4"
},
"dependencies": {
"apollo-cache-inmemory": "^1.6.6",
"aws-appsync": "^4.1.7"
}
}
then the import:
import AWSAppSyncClient from 'aws-appsync'
is flagged as needing to be deleted.
If I use 3.0.0 then the import is not flagged.
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:18 (7 by maintainers)
Top Results From Across the Web
Import code suggestions missing after upgrading to typescript ...
Try installing typescript@next into your project and switching VS Code to use it and see if the problem goes away.
Read more >moving TypeScript files in explorer fails to update/prompt ...
Create an empty project with 2 typescript files, one importing from the other. In the explorer manually move the depended upon file to...
Read more >TSConfig Reference - Docs on every TSConfig option
This technique lets you generate types ahead of time for the non-code source files. Imports then work naturally based off the source file's...
Read more >July 2018 (version 1.26) - Visual Studio Code
Add all missing imports Quick Fix. The Add missing import Quick Fix can now be applied to all missing imports in a JavaScript/TypeScript...
Read more >Firebase JavaScript SDK Release Notes - Google
json files for all published packages to make them compatible with TypeScript 4.7 support of Node.js ES modules. See Github issue #6300. Fixed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for replying, the performance regression is being tracked in #67 now. Should be able to get a fix out today.
We have a similar issue when trying to upgrade from
3.0.0
to3.0.1
. Here is a minimal reproduction:Create an app using
npx create-react-app organize-bug --template typescript
Install prettier:
npm i prettier prettier-plugin-organize-imports
src/models/Tip.ts
src/App.tsx
prettier-plugin-organize-imports
removesimport { Tip as TipModel } from "./models/Tip"
: