Skip to content

Minification interferes with generic functions #38005

Closed
@ciriousjoker

Description

@ciriousjoker

This tracker is for issues related to:

  • dart2js

  • Dart SDK Version (dart --version)

2.4.1

TLDR:

Minification changes generic type names which could lead to problems if they're hardcoded.

Example code:

class A {}

void doSmth<T>() {
    switch(T) {
      case A:
        // This will never be reached since during runtime,
        // T might be mB or some other minified string
        doSmthElse();
        break;
    }
}

doSmth<A>();

Proposed solution:
Don't minify generic type names.

Are there any workarounds? I've tried using enums but it doesn't work like Typescript..

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dart2js

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions