npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts-extended-deprecation-plugin

v1.4.6

Published

A TypeScript Language Service plugin for detecting and highlighting deprecated symbols with annotations. Provides diagnostics and hover tooltips for deprecated symbols across TypeScript and JavaScript projects.

Downloads

783

Readme

GitHub Actions Workflow Status NPM Version NPM Downloads

Example Output

AFTER: The plugin automatically highlights deprecated symbols directly in the code editor for immediate visibility.

Usage

Installation

You can install ts-extended-deprecation-plugin as an npm package:

# Install the package locally
npm install --save-dev ts-extended-deprecation-plugin

Or with Yarn:

yarn add -D ts-extended-deprecation-plugin

Note: If you're using Visual Studio Code, you'll have to use the first approach above, with a path to the module, or run the "TypeScript: Select TypeScript Version" command and choose "Use Workspace Version", or click the version number between "TypeScript" and 😃 in the lower-right corner. Otherwise, VS Code will not be able to find your plugin. See https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin#testing-locally

Configuration

To use this plugin in your TypeScript project, add it to your tsconfig.json:

{
    "compilerOptions": {
        "plugins": [
            {
                "name": "ts-extended-deprecation-plugin"
            }
        ]
    }
}

This configuration will enable the plugin and allow it to detect deprecated symbols in your TypeScript/JavaScript code.

How it Works

The ts-extended-deprecation-plugin hooks into the TypeScript Language Service, detecting any symbols marked with @deprecated in your project. When it finds a deprecated symbol, it does the following:

  1. Hover Tooltip: Displays a hover tooltip in your editor with a deprecation message.
  2. Diagnostics: Adds a warning to the diagnostics view with details about the deprecated symbol, file, and location.

Plugin Options

You can extend the functionality with custom options in tsconfig.json. Currently, this plugin works automatically without additional configurations, but future releases may allow more granular control over the behavior.

Example Scenario

Consider this code:

// In your file.ts
/**
 * @deprecated Use newFunction instead
 */
export function oldFunction() {
    // ...
}

// Usage in another file
import { oldFunction } from "./file";
oldFunction(); // <-- Hovering over this will display a deprecation warning

The plugin will display a strikethrough in your editor and provide a tooltip indicating that oldFunction is deprecated.

Performance Insights

The plugin is lightweight and integrates seamlessly with the TypeScript compiler, so it won’t impact performance noticeably, even in large projects.

Major Use Cases

  • Tracking Deprecated Code: Identify deprecated functions, classes, variables, and more in your project and ensure your codebase remains up to date.
  • Maintaining Code Quality: Warn developers about deprecated code and encourage the use of newer alternatives.
  • Cross-File Detection: Works across multiple files in large codebases, even when deprecated symbols are re-exported or aliased.

Troubleshooting

Why isn’t the plugin detecting deprecated symbols?

Ensure the following:

  1. The plugin is added to your tsconfig.json under compilerOptions.plugins.
  2. The symbol is marked with @deprecated in a comment right before the declaration.

How to view more details about deprecated symbols?

Warnings about deprecated symbols will appear in the diagnostics view in your IDE (such as VSCode). Hovering over the symbol will display the deprecation message in a tooltip.

Support the Developer

If you find this plugin useful, consider supporting its development:

"Buy Me A Coffee"

Maintainers

Contributing

We welcome contributions to ts-extended-deprecation-plugin! Please see CONTRIBUTING.md for more details.