-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Add // @ts-ignore to typescript.d.ts AssertClause and AssertEntry entries for API backwards compatibility? #56954
Comments
Can we just duplicate the declaration and deprecate one of them? Since they are structurally identical, they would be assignable to each other. Not thrilled about having to special case this one thing in the dts bundler. (A regular comment like this will not be preserved and has no precedent.) |
We preserve it in the dts by making it a block comment π I'm more than happy if you guys wanna duplicate it and yeah it sucks that we need to keep this hack around. Sadly though we'll be stuck with a hack until you guys remove it. We won't be able to remove ours until we bump our dep min past 5.3 |
If you get a chance, can you try the package built on #56967 to see if that "fixes" the problem? |
π that fixes it! https://github.com/JoshuaKGoldberg/repros/tree/ts-eslint-tsc-assert-entry-clause-clash has a repro. |
@JoshuaKGoldberg We realized in the design meeting that there is likely a much simpler fix; in your declarations, can you just specify the /** added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
export interface AssertClause extends ts.Node {
kind: ts.SyntaxKind.AssertClause;
}
/** added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
export interface AssertEntry extends ts.Node {
kind: ts.SyntaxKind.AssertEntry;
} |
Hm, it seems like it doesn't work alone in your repro repo. I get fewer errors:
However, having them do this does work: /** added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
interface AssertClause extends ts.ImportAttributes {
}
/** added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
interface AssertEntry extends ts.ImportAttribute {
} Or even: /** added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
interface AssertClause extends ImportAttributes {
}
/** added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
interface AssertEntry extends ImportAttribute {
} This would allow TS to not have to change anything. I would expect those to work because you're already having to declare these two new types for older TSs anyway? |
I just tested the above two examples forcing TS 5.2, and they both compiled (well, almost; they complain about |
typescript-eslint/typescript-eslint#8181 I tried this on 5.2 and it errored. I'll check again in a bit - maybe I did something wrong in my test. |
So as a base install with no changes:
Then if I manually patch /** added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
interface AssertClause extends ts.ImportAttributes {
}
/** added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
interface AssertEntry extends ts.ImportAttribute {
}
I'm so confused right now - I tested the above fix several times and it broke on TS5.2 with an error because it said that the interfaces had a different parent - that's why I ended up closing the PR and leaving that comment. Well I guess I'll reopen and land that PR then π€· |
Well, I'm glad it works, anyway! That other linked PR didn't seem to allude to what broke, unless I misread something... |
|
π Search Terms
api breaking change interface merge assert clause entry import attribute attributes
β Viability Checklist
β Suggestion
The
AssertClause
andAssertEntry
interfaces in TypeScript 5.3.3 clash with their declarations in typescript-eslint - even after #56485. We don't see a way to resolve this for users. For the sake of backwards compatibility, could the types be given// @ts-ignore
s so that folks don't have toskipLibCheck
?...and in general, whenever a type is
@deprecated
, could it be given a// @ts-ignore
?π Motivating Example
We haven't been able to figure out a way to fix this for users of typescript-eslint who want to keep
skipLibCheck
disabled.I realize how gross it is to suggest
// @ts-ignore
inside TypeScript's types, but short of moving the types to DefinitelyTyped orpatch-package
, I'm out of ideas...π» Use Cases
typescript-eslint uses interface merging to ensure types for newly-added nodes are present regardless of TypeScript version:
Paraphrasing @bradzacher's typescript-eslint/typescript-eslint#8047 (comment):
AssertClause
andAssertEntry
with standard interfaces (interface AssertEntry extends Node { ... }
)type
aliases (type AssertEntry = ImportAttribute
), which broke interface merging in typescript-eslintinterface AssertEntry extends ImportAttribute { ... }
)...but the 5.3.3 change didn't fix type checking on
typescript.d.ts
complaints for users. typescript-eslint/typescript-eslint#8047 shows project links & reports from users reporting they need to enableskipLibCheck
:The text was updated successfully, but these errors were encountered: