GithubHelp home page GithubHelp logo

vscode-inline-types's People

Contributors

axetroy avatar martinjohns 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

Watchers

 avatar  avatar  avatar  avatar

vscode-inline-types's Issues

Not working if tsconfig.json is not found at the root folder

It won't work if /tsconfig.json doesn't exist. I think this is an issue because if you are using a mono-repo (lerna, yarn workspaces, yamat, rush, etc) then you probably don't have a tsconfig.json at the root, but in a child folder. I think this should search for a tsconfig.sjon in the closest folder to the current file. Also I think typescript compiler API has a function for this (given a .ts file find the tsconfig.json file that apply to it. ) My two cents

This is my config:
node -v
v10.4.0
npm -v
6.1.0
tsc -v
Version 2.9.2
vscode : 1.24.1
OS: linux (arch)

Thanks

Make type renders their own characters

"Make type renders their own characters instead of having them be attached to the previous character."

As it is now if a type is defined as const foo: string = 'Hi'; then moving cursor from here const fo|o: string = 'Hi'; one step to the right will move the cursor all the way over there const foo: string |= 'Hi';. I purpose that it instead moved the cursor to here const foo|: string = 'Hi'; and then if you moved once more to the right we would end up over there const foo: string |= 'Hi';

Configurable colour

I'm using a light theme and the inline types are difficult to read:

image

Could the extension provide a way to customise this colour?

feat: consider support inline-type in IfStatement

why will I need this feature?

because we often write such code:

const arr: any[] = [];

if (arr) {
  // this block always run
}

The decorator can remind us, what type of the condition expression.

because condition should be a boolean, not an array or object.

Array and Object always equal true, even it's empty. It makes us confused.

1

and it's useful to check some mistake

for example:

Wrong: Missing await

1

Correct

1

PSA: Extension is no longer needed because this feature has been implemented natively

For anyone else that stumbles across this extension/repository: this extension is no longer needed because the feature has been implemented natively in VS Code.

Simply add the following settings to your settings file

"javascript.inlayHints.enumMemberValues.enabled": true,
"javascript.inlayHints.functionLikeReturnTypes.enabled": true,
"javascript.inlayHints.parameterNames.enabled": "all",
"javascript.inlayHints.parameterTypes.enabled": true,
"javascript.inlayHints.propertyDeclarationTypes.enabled": true,
"javascript.inlayHints.variableTypes.enabled": true,
"typescript.inlayHints.enumMemberValues.enabled": true,
"typescript.inlayHints.functionLikeReturnTypes.enabled": true,
"typescript.inlayHints.parameterNames.enabled": "all",
"typescript.inlayHints.parameterTypes.enabled": true,
"typescript.inlayHints.propertyDeclarationTypes.enabled": true,
"typescript.inlayHints.variableTypes.enabled": true

or search for "inlay" in the settings UI and toggle the settings from there.

Toggling the hints will look as follows:

Parameter type inlay hints
image

Variable type inlay hints
image

Property type inlay hints
image

Return type inlay hints
image

See the official documentation on this feature here -> https://code.visualstudio.com/docs/languages/typescript#_inlay-hints
See this video showing the feature -> https://www.youtube.com/watch?v=tY4mrgW3jcM

Implement this as a Language Service Plugin

This will substantially improve this extension.
You will get better performance, will always use the same ts version that the user uses and don't have to care about tsconfigs any more.

See here for a demo.

[Feature] Allow configuration of the extension

Description:
Allow configuration of the extension using the VS Code settings to disable / enable distinct features of this extension.

Example:
In the User Settings settings.json:

{
    "inlineTypes.feature.functionReturnType": false,
    "inlineTypes.feature.variableType": false
}

Option to automatically write the inferred definition

It would be great to have a contextual menu option or a light bulb option that would write automatically the inferred definition. For example:

image
Right now the extension is inferring the string return type. So if I choose some option like "Write definitions explicitly" it would turn my method into this:
image
So the inferred type is not displayed anymore because it's actually written in the code.

[Bug] module name is omitted for imported types

Example code:

import * as ts from 'typescript';
function getSourceFile(): ts.SourceFile { return {} as ts.SourceFile; }

const sourceFile = getSourceFile;

Actual decoration:

const sourceFile: SourceFile = getSourceFile();

Expected decoration:

const sourceFile: ts.SourceFile = getSourceFile();

[Feat Request] support inline params name

This extension is awesome and useful.

Can you consider to add a feature for CallExpression AST node?

before:

function getUserInfo(name: string): void {
  //
}

getUserInfo("username");

after:

function getUserInfo(name: string): void {
  //
}

// "name: " is a decorator, create by extension
getUserInfo(name: "username");

Decoration styles (default or overridden) are not applied when the effective type is `any`

See here:
image

The highlighted types are coming from the extension not written in the file. I don't why they keep showing with white color. I can override color and opacity from config but it still won't affect these 2 as shown in the picture.

It's very weird because in the picture we can see only one of the types shown for a const is affected by this issue. The others are fine.

[Feature] Introduce update-delay

Description:
Currently the extension updates the decorations on every key stroke. This introduces a lot of flickering and updates when writing a function, as the inferred type can change a lot while typing. A configurable (depends on #3) delay should be added, which delays the update of the decorations for a specified duration after the last keystroke.

[Bug] Return type of methods is not rendered

Example code:

class TestClass {
    public testMethod(arg: string) {
        return arg;
    }
}

Actual decoration:

public testMethod(arg: string) {

Expected decoration:

public testMethod(arg: string): string {

Not working for types defined in libraries

image

This is my tsconfig:

{
  "compilerOptions": {
    "target": "es6",   
    "module": "commonjs", 
    "moduleResolution": "node",
    "lib": ["es2018", "dom"],
    "outDir": "./dist", 
    "rootDir": ".",
    "strict": true, 
    "strictNullChecks": false,
    "noImplicitAny": true,
  }, 
  "include": [
    "src"
  ]
}

Work on tsx files

It would be great if this plugin also worked on files with a tsx extension.

With or without that though this is one of my fave plugins right now! Amazing work!

[0.3.0] No types visible for typescript nor typescriptreact

I installed the latest version, and enabled it for my workspace. Our project is relatively large (maybe?), and I was getting no output from the plugin (I tested it a couple weeks ago, and it worked on a plain TS file, then).
It also appeared to hang / interfere with normal type checking.

I tested in pure .ts files, and in .tsx, and I got no output. I didn't see any errors anywhere, but I don't know where to look.

I'm happy to test more things, just let me know what information I could provide or where I could look for debug output.

VSCode @ Version 1.24.1 (1.24.1)

[Improvement] Add testing

Description:
Currently nothing in the code is automatically tested. This of course is not very nice. Tests for old features should be added.

[Improvement] Add logging

Description:
Currently only debug logs exist, which are not helpful to the user of the extension. Instead of, or additionally to, those debug logs proper log calls should be added, which are available using an Output window in VS Code. This shows more transparency showing what the extension is doing when.

[Feature] Render decoration for inferred Type Arguments

Example code:

interface Result<TData1 = undefined, TData2 = undefined> {
    readonly data1: TData1;
    readonly data2: TData2;
}

function testResult0(): Result { return { data1: undefined, data2: undefined }; }
function testResult1(data1: string): Result<string> { return { data1, data2: undefined }; }
function testResult2(data1: string, data2: number): Result<string, number> { return { data1, data2 }; }

const test0 = testResult0();
const test1 = testResult1('test');
const test2 = testResult2('test', 0);

Expected decoration:

function testResult0(): Result<undefined, undefined> { .... }
function testResult0(): Result<string, undefined> { .... }

const test0: Result<undefined, undefined> = testResult0();
const test1: Result<string, undefined> = testResult1('test');

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.