Skip to content

Removing unused imports "feature" #4717

Closed
@nullptr128

Description

@nullptr128

Hello!

I recently stumbled upon a bit weird error which made me lost a bit of time. I am using TypeScript in client side SPA application with browserify (TypeScript module setting is "commonjs"). I found out that compiler has weird feature of silently removing "dead" imports that are not used within module code.

This should not work this way as it breaks code, because some libraries actually just extend other ones, with the example being Knockout Punches. This leads me to make a stupid workaround just to "cheat" TypeScript compiler. This behaviour shuold be documented and it should be configurable.

Code: http://pastebin.com/0dSyzieq

Removing fakeArray causes line 25 (ko.punches.enableAll()) to break in runtime because TS skips this import and knockout.punches library is not extending base Knockout at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadCanonicalThis issue contains a lengthy and complete description of a particular problem, solution, or design

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions