d-kimuson / ts-type-expand Goto Github PK
View Code? Open in Web Editor NEWvscode extension for expand type of typescript
License: MIT License
vscode extension for expand type of typescript
License: MIT License
Add some options to allow users to setup auto expansion or at least expand the first level automatically.
In Windows, I get the following error when selecting a node
Error: Node is not defined
at JP.getTypeFromLineAndCharacter (C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:627:2978)
at C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:627:4637
at HC.middlewares (C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:618:122618)
at d (C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:627:179)
at next (C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:627:282)
at n (C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:618:121620)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async d (C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:627:173)
at async next (C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:627:276)
at async d (C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:627:173)
at async next (C:\\Users\\owner\\.vscode\\extensions\\kimuson.ts-type-expand-1.0.1\
ode_modules\\ts-type-expand-plugin\\dist\\index.js:627:276)
Code base is here.
Resolve this problem and make it usable for Windows
Add a copy feature so that all the properties and sub-properties are copied to the clipboard.
I frequently work with generics and complex types. I would like the ability to copy the types so that I can more easily work with AI.
Copy could either copy only the expanded properties or copy all nested properties. I recommend having a setting to limit nested depth to prevent infinite loops for the 'all nested properties' option.
Quite frequently I need to find a property within a type, and if the type is composed (a union) all of the properties are a mixed jumble. It would help a lot if we could hotkey to sort the properties within a node, and leave the default sorting mode for all tree generation until we change it.
Thanks!
It works for simple types, but I have some types deep in my project that typescript is kindly showing as a string
on hover but the extension sidebar claims it is of type any
.
It would help if we could do a quick search for props within an object.
You can see this feature implemented in another similar project: TypeScript Explorer
One difference that I'd like to see is the ability to show Only the props that match a specific filter. In the example we see the existing tree is modified with styling. That's good for some purposes, but for others it helps to just see what we want at that moment.
Also note that when filtering for 'onclick' that implementation shows "on" and "click" as well as "onclick". While that could be helpful in rare circumstances I find that to be annoyingly too (non)intuitive. YMMV
You might be able to incorporate the FOSS from that project (with proper attribution of course) as a starting point for this enhancement, or even as-is as just the first version of this feature.
Thanks!
Can I start by saying I absolutely love this extension, and I can't believe I have only just found it! Super super useful stuff.
I wanted to let you know that the display of the type-tree doesn't seem to render at all in the new 1.x
version. I was able to use it just fine with the latest 0.x
version, so that's what I'll be using for now, but felt I should make a bug report.
I am on an Intel MacBook Pro (2019) running Monterey 12.6.3. When I try to load the updated extension I get the toast activation message saying it is ready to use, and the title of the sidebar section reads TS TYPE EXPAND (ACTIVE)
but the section is completely blank no matter what files I open or what types I click on.
Let me know if you need any more details. Thanks for all your hard work!
function foo(arg1: string, arg2: string): number {
let Foo: string // this is registered as arg3
const f = () => ... // this is regsited as arg4
}
Functions defined within a function are also expanded as argument types.
Many properties starting with _ are private and often noisy.
I would like to provide an option to make this optional.
Also, it would be better to have the sort order backward by default
string literal type should not be expandable
Installed it, restarted VSCode and opened the TS-Type-Expand window, but nothing happens when I click different types in the editor, it's just blank and empty.
Volar (extension for working with Vue) has a takeover mode in which you disable built-in TypeScript extension and use Volar exclusively, which makes it more performant, because then only 1 language server needs to be created. Unfortunately, this makes it impossible to use this extension, because it depends on the built-in TypeScript extension. It would be great if both could work together, since theoretically Volar should be just an extended built-in language server (although I cannot tell for sure).
It has become too much of a hassle to set up watch in parallel with multiple package dependencies during development.
Currently, building the Compiler API program in watch mode, so we are picking up
If you can receive the type information from VSCode's Language Server by some means, all these problems will be solved.
I found an issue that might be useful, so I created an issue.
I'm using this extension in a Deno project, not a Node project. Maybe that's relevant.
The error only appears when I position the cursor on anything I've imported from an external library.
All my imports of external libraries are done the Deno way, so they look like:
import { xml2js as xml2pojo } from "https://deno.land/x/[email protected]/mod.ts";
And they are cached locally by Deno.
When I hover over the line where I call the function, VSCode is able to show my the type definition of the function, so VSCode itself is not having any troubles:
I am just unsatisfied that I can't see what the type of the 2nd function argument (userOptions: Xml2JsOptions
) expands into without cmd + click on the function name to navigate to the source file. I was hoping this extension could fix that.
But when I position my cursor on the function name xml2pojo
the extension shows nothing and the logs say:
Error: Unexpected intrinsicName Error, [object Object]
I'm doing a little debugging and I think I have found some useful information. When I cmd + click to go to the source file of the imported xml2js
library then this extension doesn't work in that file at all. It raises the error:
SourceFile not found: /https/deno.land/x/[email protected]/xml2js.ts
So I'm just guessing this extension can't work with Deno because:
Is that a fair assessment? Please I would super appreciate it if you could fix this.
These screenshots will immedaitely clarify the request.
Note mouseover on config
reveals the type to be AppConfigJson.
Yes, the treeview shows the typename on mouseover but if there is a type, can we have an option to see it in the tree without mouseover?
As another example, note this code and then see how the tree shows it:
type ReactStyles = Record<StyleKeys, CSS.Properties>
type MuiStyles = Record<StyleKeys, CSS.Properties>
...
styles: {
current: () => ReactStyles
react: ReactStyles
mui: MuiStyles
}
There is plenty of room there to show "Properties (ReactStyles)".
Thanks!
Hello!
First off: fantastic extension! This adds some sorely needed typing information not provided out of the box with VScode, to say the least!
One issue of note which I believe is not touched upon by the other issues (apologies if I'm incorrect) is that mapped-types resolve as "unsupported". For example:
type OneToThree = 1 | 2 | 3;
type MappedOneToThree = {
[key in OneToThree]: string;
};
would have an expected expanded type of:
MappedOneToThree
1: string
2: string
3: string
but instead yields:
MappedOneToThree
1: unsupported
2: unsupported
3: unsupported
Again, though, thank-you so much for this wonderful extension!
I installed the extension, went into the solution explorer to try it, and got a popup from Windows asking me if I allow VSCode to access my network.
Why? This make it look like a malicious extension.
It simply stopped working - no error and nothings shows up. Is there any problem with WSL2 (Windows Subsystem Linux)?
Thanks for the great extension. Would be great if it can support monorepo setups like Yarn workspaces that has multiple tsconfigs across the different packages in the monorepo.
Whatever type I select, nothing never appeared inside the panel
Here is a single example:
VSCode Typescript version: 4.4.2
Local Typescript version: 4.1.6
Note this type definition and assignment:
This seems related to #331 where in this case "end"
is a literal type, not itself a "type".
The actual type of that property is: "bottom" | "top" | "end" | "start" | undefined
That's what I expected to see for that property as the type, not the value, which is of type 'end'.
I know this is complex. :)
Don't we expect "CSS.Property.BackgroundColor | undefined" there and not the value?
Thanks.
Love this extension! What an awesome effort here. Thank you 🙌🏻 .
Anyway, I'd like to request a feature to "pin" a type or in some way, keep a type active in my viewable field while I change active editors.
I am going to start looking for ways to contribute to the VSCode side of things, so perhaps I will try to achieve something for this, but if you have a preference about a way to do this, let me know. I guess a first good step would just be a little pin icon beside the expanded type which would keep it active until unpinned.
The extension doesn't seem to work on my side. Here is the error I get:
{
"context": "ts-type-expand",
"level": "error",
"message": {
"error": {
"data": {
"code": "INTERNAL_SERVER_ERROR",
"httpStatus": 500,
"path": "getTypeFromPos",
"stack": "TRPCError: error: Error: Node is not defined\n at /home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:4962\n at HC.middlewares (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:618:122618)\n at d (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:179)\n at next (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:282)\n at n (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:618:121620)\n at process.processTicksAndRejections (node:internal/process/task_queues:96:5)\n at async d (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:173)\n at async next (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:276)\n at async d (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:173)\n at async next (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:276)"
},
"meta": {
"response": {
"size": 0
}
},
"name": "TRPCClientError",
"shape": {
"code": -32603,
"data": {
"code": "INTERNAL_SERVER_ERROR",
"httpStatus": 500,
"path": "getTypeFromPos",
"stack": "TRPCError: error: Error: Node is not defined\n at /home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:4962\n at HC.middlewares (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:618:122618)\n at d (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:179)\n at next (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:282)\n at n (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:618:121620)\n at process.processTicksAndRejections (node:internal/process/task_queues:96:5)\n at async d (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:173)\n at async next (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:276)\n at async d (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:173)\n at async next (/home/victus/.vscode/extensions/kimuson.ts-type-expand-1.0.1/node_modules/ts-type-expand-plugin/dist/index.js:627:276)"
},
"message": "error: Error: Node is not defined"
}
},
"kind": "TRPC_SERVER_ERROR"
}
}
src/utils/logger.ts
process.env["HOME"]
is not defined
I'm using Windows 11
There seems to be something wrong with the handling of async function objects.
Steps to Reproduce
foo
.const foo = async () => { };
Expected
ts-type-expand
displays the return type of foo
as Promise<void>
.
Actual
It displays this type as void
.
Additional info
const bar= async (): Promise<void> => { };
will be displayed as any
.
const name: string // here
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.