Giter Club home page Giter Club logo

Comments (6)

rlnt avatar rlnt commented on May 12, 2024 1

It looks like I am not able to reproduce this behavior anymore.
I reinstalled the plugin and tried running prettier from the command line like you said and it worked.

After that, I tried auto-formatting by saving again but it worked without any error. Really odd.
I reinstalled my OS in the last few days because I had problems with the update and that seems to have fixed it for now.

I will reopen the issue if I am able to reproduce this again. Thanks for your help!

from prettier-plugin-organize-imports.

simonhaenisch avatar simonhaenisch commented on May 12, 2024

Just looking at the call stack, it looks like the code that causes this is part of the TypeScript lib (processCommentPragmas). All this plugin does is call organizeImports of the TypeScript language service, so I wonder whether you run into the same issue when you use the "Organize Imports" action via the command palette (Ctrl + Shift + P)?

Is it a very large file that you're trying to format? You wouldn't be able to provide the file for debugging purposes, would you? Otherwise I'm sorry but I think this is out of my hands as the issue is most likely upstream (https://github.com/microsoft/TypeScript/blob/master/src/services/organizeImports.ts).

from prettier-plugin-organize-imports.

rlnt avatar rlnt commented on May 12, 2024

So sorry! Didn't see you replied to the issue. I usually check my notifications every day multiple times.
Must have skipped that.

I tried using the organizeImports option from the command palette and it works fine.
I am not trying to format a large file. I can even create a new empty file and I will get the same result.

from prettier-plugin-organize-imports.

simonhaenisch avatar simonhaenisch commented on May 12, 2024

Hm ok, however I'm sorry but I'm not able to reproduce this. I don't have a Windows machine around.

I've added cross-platform matrix testing to the CI now to make sure the plugin code works on all platforms. It does: https://github.com/simonhaenisch/prettier-plugin-organize-imports/actions/runs/468671986.

The only thing I can think of is that it's an issue with the TypeScript version in your project. From looking at your log file I can tell that VS Code is not using the built-in TypeScript version but the one that's locally installed into your project. Which one is that? Also, which Node version are you on?

from prettier-plugin-organize-imports.

rlnt avatar rlnt commented on May 12, 2024

I am using Windows 10 Pro but my whole development environment is sitting in the WSL 2 environment which is running Ubuntu 20.02.
I am running TypeScript 4.1.3 in my project.
Node is running on 15.5.0.

from prettier-plugin-organize-imports.

simonhaenisch avatar simonhaenisch commented on May 12, 2024

Ok I'm using similar versions (same prettier, same plugin, same typescript, and Node 15.3), and everything works fine for me (however I'm on macOS).

What you can try to do is invoke prettier from the command line in your project:

npx prettier --write path/to/some/file.ts

If that runs into the same issue, then at least we know it's not related to VS Code. In that case, can you also try to create a clean project and see whether it reproduces?

mkdir organize-imports-test
cd organize-imports-test

npm init -y
npm install --save-dev prettier prettier-plugin-organize-imports

touch file.ts

npx prettier --write file.ts

from prettier-plugin-organize-imports.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.