这是indexloc提供的服务,不要输入任何密码
Skip to content

🐛 Knip marks files declaring modules or globals as unused #1354

@remcohaszing

Description

@remcohaszing

Prerequisites

Reproduction url

https://github.com/remcohaszing/knip-repro-declare

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

When a file declares or augments a module or global, that means the file is used. The same goes for triple-slash directives.

Example augmentation (from a module):

declare module 'knip';

Example module declaration (from a script):

declare module 'some-module';

Global declaration (from a module):

declare global {
  const variable: string
}

Global declaration (from a script):

declare const variable: string

Triple slash directive (from a script or module):

/// <reference types="knip" />

I don’t think Knip has a full TypeScript context. Without that, it’s not always possible to tell a script apart from a module. So I don’t really expect Knip to be able to handle the case of variable declarations in a script.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions