GithubHelp home page GithubHelp logo

miaonster / vscode-definition-filter Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 0.0 175 KB

Filter any user-specified typescript definition.

TypeScript 100.00%
tsserver typescriptserverplugins definition

vscode-definition-filter's Introduction

TSX Definition Filter

VSCode marketplace unique identifier: vscode-tsx-arrow-definition

Feature

  • Remove react definition of arrow function
  • Remove user-specified definitions if there're mulitple
  • Remove any user-specified definition

Before

before

After

before

Install

https://marketplace.visualstudio.com/items?itemName=miaonster.vscode-tsx-arrow-definition

or search extension marketplace:

vscode-tsx-arrow-definition

Configuration

  • remove

    • Default: ["**/node_modules/@types/react/index.d.ts"]
    • Type: Array of Rule
    • Description: If mulitple definitions exist and one of the definitions matches any Rule, remove that definiton.
  • forceRemove

    • Default: []
    • Type: Array of Rule
    • Description: If one of the definitions matches any Rule, remove that definiton.

Rule

Rule is a string of glob pattern or { file, definition }

  • file is a string of glob pattern which matches the file path you're coding
  • definition is a string of glob pattern which matches the paht of deifnition file.

And see minimatch for more details of glob pattern.

Example

// settings.json
{
  "tsxDefinitionFilter.remove": [
    "**/node_modules/**/*",
  ],
  "tsxDefinitionFilter.forceRemove": [
    {
      "file": "**/src/**/*",
      "definition": "**/*.scss.d.ts",
    }
  ]
}

Motivation

Due to this issue, Cmd+click of JSX component will show 2 definitions. One of the definition is FunctionComponent of react. This behavior is not desired. So let's remove that definition, just remain the correct one.

Before this extension, I created a tsserver plugin, typescript-react-go-to-definition-plugin, for normal extension can only add additional definition. Only typescriptServerPlugins can modify the behavior of tsserver.

vscode-definition-filter's People

Contributors

miaonster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.