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

typescript-vscode-sh-plugin

v0.7.3

Published

TypeScript plugin that provides richer semantic highlighing

Downloads

2,227

Readme

A TypeScript plugin that replaces getEncodedSemanticClassifications and getEncodedSyntacticClassifications to provide more classifications to be used by the new Semantic Highlighting APIs in VS Code.

The purpose of this plugin is to test and enable the new VS Code semantic highlight capabilities.

Once proven, the extended classifications will (hopefully) be adapted by the TypeScript language server and the plugin is no longer needed any more.

New Classifications

The plugin uses new token classifications, consisting of a TokenType and with any number of TokenModifiers.

export const enum TokenType {
	class, enum, interface, namespace, typeParameter, type, parameter, variable, enumMember, property, function, member
}

export const enum TokenModifier {
	declaration, static, async, readonly, local, defaultLibrary
}

Classification Encoding

The new classifications are retured in place of old the classifications. They are encoded as follows:

TSClassification = ((TokenType + 1) << 8) + TokenModifierSet;

All new classifications have a value >= 0x100 to not overlap with the old classifications. Old classifications are no longer emmitted once the plugin is active.

Implemented Features

Examples for each feature can be seen in the test cases. To try them out in VSCode, copy the added snippet to a TypeScript editor and use the Developer: Inspect Editor Tokens and Scopes command to see the semantic token information ar the current cursor location.

  • all token types listed above
    • classification for all declarations and references
    • modifier declaration when on the identifier of the declaration node
        class A { field: number; member(param: number) { let var= param + this.field; } }
    • modifier defaultLibrary when in an symbol that comes from the default libraries.
        Math.max(Number.Nan, parseInt('33'))
  • variables, properties and parameters
    • modifier readonly when defined as const or readonly
        const var;
    • modifier local when not declared top-level
         function global(p: number) { const global; 
  • functions and members
    • modifier async when defined as async
    • modifier static when defined as static -variables & properties with constructor signatures
    • variables & properties that have a constructor type, are classified as class
         Number.isInteger(1);
  • variables & properties with call signatures
    • variables, properties and parameters that have a function type (but no properties) are classified as function resp member (#89337)
         const callback = () => {};
    • if the variable/member/parameter type is callable but also has properties, it stays a variable/member/parameter, unless used in a callExpression
         var fs = require('fs); require.resolve('foo/bar');
  • jsx
    • no semantic highlighting for JSX element names (for now): #88911 #89224.

Under discussion

  • add typeAlias pas a new token type
  • object literal keys are currently also classified as properties

Try it out

In VS Code

  • make sure semantic highlighting is enabled (on by default in insiders and since 1.43 in stable) "editor.semanticHighlighting.enabled": true
  • open a TypeScript or JavaScript file in VSCode and wait for the language server to get active
  • use the Developer: Inspect Editor Tokens and Scopes command to inspect the semantic information at a given cursor location.

Inspect Editor Tokens

Run the Tests

  • yarn && yarn test in the folder of the cloned repo.