Skip to content

Reduce number of d.ts files and types published in packages #1121

@mjbvz

Description

@mjbvz

Problem

The published npm package for vscode-languageclient currently includes a d.ts file for every .js file under lib:

Screen Shot 2022-11-10 at 4 34 13 PM

This is problematic for two reasons:

  • It bloats the package size. All the d.ts files in vscode-languageclient take up 300KB or so

  • We are likely publishing interfaces and types that are not meant to be exposed externally. For example, there are files like utils/async.d.ts.

Proposed fix

To fix this, I suggest adopting a tool such as api extractor. This lets you bundle all the types for a project into a single d.ts file. You can also control which types are exposed and which ones stay internal

I adopted this for the markdown language service: https://github.com/microsoft/vscode-markdown-languageservice/blob/main/api-extractor.json

This helped me make sure I only exposed a well defined API to library consumers

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new features or functionality

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions