Code Monkey home page Code Monkey logo

ts-error-translator's Introduction

ts-error-translator's People

Contributors

alinooshabadi avatar amritatwal avatar eddyw avatar evjero avatar forresst avatar github-actions[bot] avatar ic-768 avatar jenil777007 avatar mattpocock avatar princesseuh avatar rebstorm avatar rickmcgavin avatar rodelta avatar waynefaustorilla avatar yassineldeeb avatar yuheinakasaka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ts-error-translator's Issues

latest versions not published

There are some cool features that have been in the code base for a long time, like checking javascript files, that haven't been published to the marketplace for this extension. Wondering if this was on purpose because things aren't ready or just an oversight!

Thanks!

Translation request for 2425

Error Text

Class 'Main' defines instance member property 'log', but extended class 'ExtraMain' defines it as instance member function.

Supporting Information

Have a function defined on class Main and then override it on a class that extends Main

Consider not showing "can't find translation" if there's no translation

Example:

image

The original error is succinct and understandable enough. The "Can't find translation" section, along with bold and large text, needlessly steals attention from something that doesn't necessarily require a translation. I would prefer if this message didn't show up in such cases or, if it did, was smaller to reduce noise-to-info ratio.

Add filters/sorting for long errors

Users should have the ability to sort long errors in reverse order/normal order, since many errors are BEST viewed in reverse order. We should probably also have the ability to hide explanations for some errors, because they can become repetitive.

ts(2554) wrong translation for "Expected 1 arguments, but got 0."

For error ts(2554) Expected 1 arguments, but got 0,
I'm getting the translation The function you're trying to call needs {0} arguments, but you're passing {1}.
It should be The function you're trying to call needs 1 argument(s), but you're passing 0.

Here's the screenshot:
Typescript wrong translation

I fixed the issue and submitted a pull request.

Intellij?

By any change any plans for or ideas how to get this functionality over to intellij?

feat: Open Discussions

There's a lot to talk about in this project, enabling the discussions tab would help for brainstorming ideas and contributors' engagement with the project.

Extension causes high cpu load

  • Issue Type: Performance
  • Extension Name: ts-error-translator
  • Extension Version: 0.8.0
  • OS Version: Darwin x64 22.4.0
  • VS Code version: 1.77.3

⚠️ Make sure to attach this file from your home-directory:
⚠️file:///var/folders/nt/khr0v91901sgw0sg7z2cq9c40000gn/T/mattpocock.ts-error-translator-unresponsive.cpuprofile.txt

profile.txt

Formatting type errors

It would be super helpful if the translator can prettify types inside type mistmatch errors so it's not a single line like it is with Typescript's default errors.

As a "Language Service Plugin" to have broad support for IDEs besides vscode

Hey 👋

So, just throwing random ideas here. Instead of a vscode extension or adding an additional package, this could be wrapped as a TypeScript Language Service Plugin.

Language Service Plugins allow to report additional errors such as from a linter and technically they should have access to original diagnostics so theoretically it'd be possible to add "translated" diagnostics along side original diagnostics.

Assuming this works, then user can simply add this to tsconfig:

{
    "compilerOptions": {
        "plugins": [{ "name": "ts-error-translator" }]
    }
}

So any IDE that uses TypeScript language service would be able to load the plugin and report errors in that IDE's native way for displaying/reporting errors/messages.


I haven't personally written a TS language service plugin before, I'm slightly familiar with the APIs thought which I learned for no reason lol. If there is interest in this I could try this out when I get some time.

Lag in insert mode after recent update when combined with Vim emulation.

Recently insert mode in vim on 300+ line typescript files has really slowed down. After enabling and disabling a few plugins I isolated this extension as the cause.

I'm not 100% sure but I feel like the slow down was introduced with the new tutorial features. I've been happily using the error translator for over a month without issue until the last few days.

Specs:

  • Intel Macbook Pro 2018
  • MacOS Ventura 13.1

VSCode:

  • Version: 1.74.1
  • Commit: 1ad8d514439d5077d2b0b7ee64d2ce82a9308e5a
  • Date: 2022-12-14T10:33:40.793Z (6 days ago)
  • Electron: 19.1.8
  • Chromium: 102.0.5005.167
  • OS: Darwin x64 22.2.0

The VSCode extension does not work in file without extension with language set to Typescript

I was opening an issue about the extension not working but i've luckly decided to testing in some file other than quokka scratchpad.

While the app seems to work ok in every ts file if you create a new file and select the language in VSCode setting it to typescript the typescript will check for typing errors but the extension will not translate.

image

This is my VSCode version

Version: 1.66.2 (user setup)
Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
Date: 2022-04-11T07:46:01.075Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Windows_NT x64 10.0.19044

Support syntax highlighting and diff in markdown?

Hey 👋

Do you think it makes sense to add syntax highlighting support for markdown code?

Also, a more useful feature. Does it maybe make sense to add diff support in markdown? This'd help to easily display inline suggestions of code than should be removed + added. Sort of like GitHub suggestions or diff markdown. For example: 👇

const foo = "bar";
- type a = (typeof);
+ type a = typeof foo;

Handle 2339 when the right hand side is a promise

I had this and I think it might be useful if the translation for TS2339 could detect that the RHS is a promise on the assignment:

const { x } = foo(); // foo is async
Property 'x' does not exist on type 'Promise<{ x: something }>'.

could be translated/hinted as

Property 'x' does not exist on type 'Promise<{ x: something }>'. Did you mean to await the promise?

Repo has no formatting config (e.g: prettier)

Hey 👋

It looks like some files (e.g: engine.test.ts) were saved without formatting. In vscode - for instance - by default vscode formatter removes trailing spaces on save, so saving a file for me causes unrelated changes (removes trailing spaces and comma).

It'd be great if prettier (or any other auto-formatting tool) was set. This'd ensure there is a consistent code style regardless of code editor's default formatting.

Translation request for 2739

Error Text

Type 'AxiosResponse<any, any>' is missing the following properties from type '{ token_type?: string | undefined; access_token: string; expires_in?: number | undefined; refresh_token: string; }': access_token, refresh_token

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

Bug 🐛: VSC extension isn't supported on the web (ex: vscode.dev)

Problem

As said here you care about web support, I think this line also uses the filesystem under the hood to read the JSON file from disk and parse it, so that's probably the reason why It's not supported for the web.

image

Personally, I can't see any incompatibility issues other than using the filesystem from reading the why VSC extensions might not be supported on the web, but you know better than me(cause you wrote it), can you notice any other incompatibility issues?

Recommended solution

Instead of writing bundleErrors.json to disk then reading it using the filesystem and parsing it, why not just write a JS file (ex: bundleErrors.js) containing the parsed object and read it as a JS file like this import * as bundleErrors from './bundleErrors.js';, so that It acts like if It was written inline as part of the source code, brilliant right?

Should ignore node_modules @types declaration files

Once I added new types via @types (AKA DefinitelyTyped) modules, I started to see all sorts of info entries under the VS Code Problems tab trying to give me tips on TypeScript features that I hadn't marked as learned yet:

CleanShot 2023-01-25 at 14 44 18@2x

Doesn't seem like something you'd want to see by default.

I also couldn't get rid of these via exclude or skipLibCheck.

tips causes errors to be less visible

Highlighted 'tips' reduces the visibility of highlighted 'errors' which is a bit frustrating.

Is there are way to avoid this using any vs code Setting ?

Screenshot 2023-04-21 at 19 01 56

I use the scroll bar to navigate to errors in a large file , most often I find it easier to spot errors in a document using the default Typescript diagnostics.

So fixing this somehow would be really helpful to use tips alongside errors

Translation request for 2614

Error Text

Module '".svg"' has no exported member 'ReactComponent'. Did you mean to use 'import ReactComponent from ".svg"' instead?

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

Need a better translation for tuple range errors

Maybe this is a limitation in how typescript emits errors for range errors on a tuple type but I just ran into this and had to fix a package that was expecting a tuple of two strings but the library actually takes an array of numbers instead. This was the type

colors?: [string, string];

And when I had defined the prop like this

colors={[secondaryColor[500], secondaryColor[400], secondaryColor[200]]}

I get a few Typescript errors that don't properly describe the problem

This is one that once I realized what was going on makes sense

Type 'string' is not assignable to type 'undefined'.

Which means it expected everything after the first two props to be undefined and I gave it a string

This error makes more sense but still could be more descriptive

Type 'number[]' is not assignable to type '[string, string]'.

Basically it would be great if a more descriptive error was shown for a range error related to a tuple type, something like...

"Expected a tuple of [string, string] but you gave [string, string, string]"

Or

"Tuple type expected two arguments but received three"

Translation request for 1015

Error Text

Parameter cannot have question mark and initializer.

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

Infinite diagnostic error

I'm infinitely getting this error every time after installing this package.

[error] Cannot read properties of undefined (reading 'filter'): TypeError: Cannot read properties of undefined (reading 'filter')
    at updateDiagnostics (~/.vscode/extensions/mattpocock.ts-error-translator-0.8.0/out/extension.js:62005:36)
    at ~/.vscode/extensions/mattpocock.ts-error-translator-0.8.0/out/extension.js:62026:13
    at d.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:145)
    at w.deliver (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:2029)
    at g.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:1667)
    at P.$acceptModelChanged (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:96:11193)
    at u.N (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:11208)
    at u.M (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:10926)
    at u.H (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:10019)
    at u.G (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:9000)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:7788
    at d.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:145)
    at w.deliver (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:2029)
    at g.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:1667)
    at h.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:72:14314)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:120:15804
    at d.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:145)
    at w.deliver (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:2029)
    at g.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:1667)
    at h.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:72:14314)
    at c.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:72:17324)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:72:15795
    at d.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:145)
    at w.deliver (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:2029)
    at g.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:63:1667)
    at g.acceptChunk (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:72:12045)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:72:11332
    at Socket.l (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:72:19792)
    at Socket.emit (node:events:526:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

Here's my VSCode information

Version: 1.74.2 (Universal)
Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161
Date: 2022-12-20T10:26:09.430Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 21.6.0
Sandboxed: No

Let me know what else I should provide :D

Contributing to the project

It would be interesting if there was an markdown file explaining how to contribute to the project web/vscode extension.

Extension not activating - Runtime status "Not yet activated."

Hi there, I'm using VS Code 1.71.2 on Arch Linux.

Unfortunately I'm not getting any translated errors, I have checked the errors and they have translations here: https://ts-error-translator.vercel.app/.

I have tried reinstalling the extension, and noticed the Runtime status is "Not yet activated".

The language of my file is identified as "typescriptreact" and so should trigger activation as far as I can tell.

Is there any additional steps I need to do? Or is this a bug? I'm happy to share logs if you tell me from where.

Translation request for 2365

Error Text

Operator '+' cannot be applied to types 'boolean' and 'boolean'.

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

Bug 🐛: bundleErrors.json is a bad idea for perf

I've noticed that you've added a script in apps/vscode to bundle the errors into one Gigantic JSON file which will eventually be shipped with the extension.

And then you read this file which will eventually be Gigantic in src/extension.ts as the following:

import * as bundleErrors from "./bundleErrors.json";

That is probably going to be problematic in the future, cause the entire JSON file is loaded into memory as a static item that lives till the program exits.

That means that first of all, the extension startup is gonna be relatively slow cause It has to read the entire JSON file which is a lot of I/O, and then parse the content.

Secondly, the parsed JSON data is held in memory for the program's lifetime even though the user just needs a few fields from it at a particular time(avg. ~ 10).

It's best to stick to the previous workflow of just reading/parsing files only when needed (Ex: 1006.md & 1009.md) cause It does have a lot of advantages:

  • Faster startup.
  • Less I/O operations.
  • Less memory usage.
  • When you read a file say 1006.md and parse Its content and pass it to vscode to show it to the user, the held memory for that parsed file content will be automatically cleaned up by the garbage collector at the end of each loop iteration cause It's not a static item as if you use an import statement.

less whitespace in vs code extension

currently, the hover popup in vs code has a lot of extra whitespace covering other code:
image

what i'm suggesting that the TLDR should be on one/two lines:
edited

basically just use less space for the tldr. we're not talking about how long that mockup took me 😓

Introduce devcontainers

Devcontainers is a simple way to lower the barrier for contributors. It helps to run a pre-defined dev environment as a docker container. The integration with VSCode is seamless.

De-duplicating matched types may be a mistake

Hi 👋

So, these lines of code:

let [, ...items] = matchElem.match(nonGlobalRegex)!;
items = Array.from(new Set(items));

I think this can be a mistake and probably there could be a better way to do it.
For example TS2345 states this Property '{0}' is missing in type '{1}'. but .. {0} and {1} can be the same value:

Property 'User' is missing in type 'User'.

Which results on:

You haven't passed all the required parameters to '{1}' - you've missed out User

There are a bunch of these kind of diagnostics where several args could be different .. but also refer to either the same type or a different type / property with the same name.

I don't yet have an idea how it could be solved, just opening an issue to track it.
Raw first thought (not a solution, just the first thing I typed after finding the issue haha):

> i = "{0} is {1} but {0}"
'{0} is {1} but {0}'
> i.match(/(?<Arg>{\d})/g)
[ '{0}', '{1}', '{0}' ]

Translate quick fixes

VSCode provides quick fixes, it would be cool to see if this extension could translate the quick fixes so you know what it did to fix the error.

Translation request for 7053

Error Text

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ transparent: string; black: string; white: string; ink: string; base: ThemeColorSchema; primary: ThemeColorSchema; secondary: ThemeColorSchema; ... 4 more ...; disabled: ThemeColorSchema; }'.

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

Translation request for 2686

Error Text

'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

Update the tooltip on "Mark as learned"

As an user, I would expect the tooltip to automatically update when clicking on "Mark as learned", either update to "Unmark as learned" (+ changing colour?) or even disappearing from the tooltip.

I'm not familiar with VSCode Extensions API, but I guess this is possible.

I don't know if the present behaviour is a bug or a feature, but as a first time user this has surprised me.

Translation request for 1240

Error Text

Unable to resolve signature of property decorator when called as an expression.

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

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.