Skip to content

Abstract classes will still import the value for a computed property at runtime #33525

Description

@puppy0cam

TypeScript Version: 3.7.0-dev.20190920

abstract class import computed property
abstract class computed property imports for runtime

Code
sharedSymbol.ts

export const sharedSymbol: unique symbol = Symbol();

AbstractClass.ts

import { sharedSymbol } from "./sharedSymbol";

abstract class AbstractClass {
    public abstract [sharedSymbol]: string;
}

Expected behavior:
sharedSymbol.js is not imported by AbstractClass.js
Actual behavior:
The symbol is imported by AbstractClass.js despite it's use being omitted due to it's abstract nature

Playground Link: Unavailable due to the bug being related to imported values.

Related Issues: No, I did not find any

Activity

  1. Jack-Works commented on Mar 24, 2020

    @Jack-Works
    Contributor

    Have a try with new import type syntax 🤔

  2. puppy0cam commented on Aug 21, 2020

    @puppy0cam
    Author

    Have a try with new import type syntax 🤔

    This works properly.

  3. puppy0cam commented on Oct 24, 2025

    @puppy0cam
    Author

    In Typescript 5.9.3 this issue still exists but can be worked around by using import type {} syntax instead of import {} syntax.
    I've attached a copy of my reproduction of this bug since playground still doesn't appear to have multi-file support (or if it does I can't find it).
    typescript-bug-33525-2025-10-24.zip
    Edit: see my followup comment.

  4. puppy0cam commented on Oct 25, 2025

    @puppy0cam
    Author

    In the test case I uploaded to my above comment, I accidentally had verbatimModuleSyntax set to true.
    The bug still exists even when I disable that.
    Here's the new reproduction:
    typescript-bug-33525-2025-10-25.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JS EmitThe issue relates to the emission of JavaScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions