-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TS1166 reported for imported symbol as computed property name in generated d.ts #61360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Compiling this code in TS 5.8 (TS playground): const sym = Symbol();
const symAlias = sym;
const str: string = "";
export class MyError extends Error {
[str]: number | undefined;
[symAlias]: number | undefined;
} Produces this DTS output (TS playground): declare const symAlias: symbol;
declare const str: string;
export declare class MyError extends Error {
[str]: number | undefined;
[symAlias]: number | undefined;
}
export {}; And it doesn't have any errors in TS 5.8. It does error in TS 5.7 though: TS playground. To the best of my knowledge this works as intended. TypeScript doesn't guarantee that a declaration file generated by a newer version of TS will stay compatible with older versions. This has been called out in the release notes as a potential breaking change:
|
The bisect must have gone wrong; this was definitely changed by #60052. This was an unavoidable break; there was just no way to improve the handling of computed properties in declaration files without breaking backwards compatibility for older versions of TS that are lacking the feature. IIRC in 5.7 at least, the error can be "ignored" and technically work with the right behavior, though that's not really a workaround. |
closing as it's intended. |
as 5.8 introduces some changes that cause generated .d.ts files incompatible with previous versions of TypeScript compiler: microsoft/TypeScript#61360 (comment) This PR temporarily pinns its version to ~5.7.3 until we can upgrade to v5.8
as 5.8 introduces some changes that cause generated .d.ts files incompatible with previous versions of TypeScript compiler: microsoft/TypeScript#61360 (comment) This PR temporarily pins `typescript` version to ~5.7.3 until we can upgrade to v5.8 ### Issues associated with this PR tracking upgrading to 5.8: #33324 ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? We could upgrade to 5.8, but the incompatible output would cause a lot of warnings from api-extractor because it still bundles 5.7.3.
🔎 Search Terms
ts1166
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.7.3#code/JYWwDg9gTgLgBAbzsAdgZzAUwMbwL5wBmUEIcARChACaYBcArjMADbkDcAUJ9hOvNgZoYpOAF5k6LLgB0g4aS6dMAD0iw42FgEM0aOAFkAngFEoJKHFUxMKavrMXEnOHADa8kSAC6ACgCUdHDCUKgA5s6urlCYMAxQKBQUXK54nGmcQA
💻 Code
compiling this code with 5.8.2
🙁 Actual behavior
generates the d.ts of
Opening this in editor we are seeing error of
🙂 Expected behavior
d.ts generated by 5.7.2 is slightly different
[x: symbol]: () => string;
and has no errorsAdditional information about the issue
every-ts bisect
pointing to this commit:Same issue exists in version 5.9.0-dev.20250305
The text was updated successfully, but these errors were encountered: