TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Declaration emit not dropping untyped computed property name

Open acutmore opened this issue 1 year ago • 0 comments

🔎 Search Terms

declaration, dts, ambient, computed property

🕗 Version & Regression Information

  • This changed between versions 5.5.0-beta and 5.5.0-dev.20240514

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?ts=5.5.0-dev.20240520#code/PTAEAEGcAsHsHcCiBbAlgFwFAgjBKN0BTAEwDFUAbIgLlGQENUA7AOhNfUmzHBKIDGlBgCcG6VLGaYeEAGZUizBslqgVAI1RL07Tt35DRRerBIBXaqABEDDQP5yA5tGsBuGTnALqy1XUYWfUxUZAAHWBF0UAAVIkhouRFYZBs7ByJnVw9MIgAPCKjQI0hIUABhUABvTFA60ABtOITWSBSiAGkiAE8AXQAKAEpqgF8PEcwgA

💻 Code

// @showEmit
// @showEmittedFile: main.d.ts
// @declaration

// @filename: ambient.d.ts
declare module "abcdefgh";

// @filename: main.ts
import Test from "abcdefgh";

export class C {
    [Test.someKey]() {};
}

🙁 Actual behavior

// main.d.ts
import Test from "abcdefgh";
export declare class C {
    [Test.someKey](): void;
    // ❌ error 1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type.
}

🙂 Expected behavior

// main.d.ts
export declare class C {
}

Or alternatively it would now be an error.

Additional information about the issue

Note: this is an error when isolatedDeclarations is enabled: https://www.typescriptlang.org/play/?isolatedDeclarations=true&ts=5.5.0-dev.20240520#code/CYUwxgNghgTiAEA3W8AqIDOAXAXPKAdgJ4DcAUGSAB4AOA9jFvJFBhvAMLwDeZ8-8ANrpsAOgx0AtiADSIIgF0AFAEo8hIjwC+5LWSA

acutmore avatar May 20 '24 10:05 acutmore