background

The project needs a JSON configuration file that uses fields exported from another typescrip file to reduce the chance of field name errors during coding.

Therefore, consider developing a plug-in for:

  • The fn name is automatically completed in the JSON file
  • Custom jump from a JAon file to a typescript file
  • Intelligent prompt for error tilde lines in JSON files (tilde lines are displayed when the typescript file does not export this field)

Plugin effect:

implementation

Program source code

Automatic completion

Jump to definition

Intelligent diagnostics & tips

Key point: Use json-to-ast to convert a JSON file to an AST

Some hit the pit

  1. Executed when the plug-in is publishedvsce publishTimes wrongERROR Failed request: (401)The generated personal Access token permission is incorrect and should be selectedFull access

0d7f065c08da22fd11b8db01af81b8d9.png

  1. Error reporting plugin release:ERROR Make sure to edit the README.md file before you package or publish your extension— Modify the project insideREADME.mdFile (original file delete & rewrite)
  2. Failed to create Publisher account using address — the network was limited.
  3. The plug-in works in the local development environment, but does not respond (and does not report errors) when posted online.

    Some NPM libraries are used in the project, but TSC is used to compile the plugin. In this case, some NPM library code in node_modules is not compiled. Webpack needs to be introduced for packaging & compilation

reference

  • A comprehensive guide to VS Code plug-in development
  • VS Code Document
  • Some demo