Skip to content

Preserve computed property in --isolatedDeclarations emitΒ #61892

Open
@acutmore

Description

@acutmore

πŸ” Search Terms

isolated declarations, computed properties

βœ… Viability Checklist

⭐ Suggestion

Now that #60052 allows for (some) computed properties in in .d.ts files I think the next step is for --isolatedDeclaration to be updated to not error and to emit the computed properties. Opening this issue if helpful to track this work.

I believe the previous plan (#58800) to introduce a new syntactic marker is no longer required.

Related issues: #58533 #60818 #61068

πŸ“ƒ Motivating Example

export const prop: unique symbol = Symbol();

export class MyClass {
    [prop] = () => Math.random();
}

@isolatedDeclarations: false

playground

export declare const prop: unique symbol;
export declare class MyClass {
    [prop]: () => number;
}

@isolatedDeclarations: true (current πŸ™)

playground

ts(9038) Computed property names on class or object literals cannot be inferred with --isolatedDeclarations.
export declare const prop: unique symbol;
export declare class MyClass {
}

@isolatedDeclarations: true (future πŸš€ )

No error and same emit as @isolatedDeclarations: false

export declare const prop: unique symbol;
export declare class MyClass {
    [prop]: () => number;
}

πŸ’» Use Cases

The primary use case is enabling isolated declarations at scale on large codebases that make heavy use of computed properties.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions