Description
π Search Terms
api breaking change interface merge assert clause entry import attribute attributes
β Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
β Suggestion
The AssertClause
and AssertEntry
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 to skipLibCheck
?
/** @deprecated */
+ // @ts-ignore
interface AssertEntry extends ImportAttribute {
}
/** @deprecated */
+ // @ts-ignore
interface AssertClause extends ImportAttributes {
}
...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 or patch-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:
// Workaround to support new TS version features for consumers on old TS versions
// Eg: https://github.com/typescript-eslint/typescript-eslint/issues/2388, https://github.com/typescript-eslint/typescript-eslint/issues/2784
declare module 'typescript' {
/** @ts-ignore - added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
export interface AssertClause extends ts.Node {}
/** @ts-ignore - added in TS 4.5, deprecated and converted to a type-alias in TS 5.3 */
export interface AssertEntry extends ts.Node {}
Paraphrasing @bradzacher's typescript-eslint/typescript-eslint#8047 (comment):
- TypeScript 4.5 - 5.2 declared
AssertClause
andAssertEntry
with standard interfaces (interface AssertEntry extends Node { ... }
) - TypeScript 5.3 changed them to
type
aliases (type AssertEntry = ImportAttribute
), which broke interface merging in typescript-eslint - Make AssertEntry and AssertClause interfacesΒ #56485 -> TypeScript 5.3.3 changed them to interfaces (
interface 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 enable skipLibCheck
:
node_modules/typescript/lib/typescript.d.ts:6021:15 - error TS2320: Interface 'AssertEntry' cannot simultaneously extend types 'ImportAttribute' and 'Node'.
Named property 'kind' of types 'ImportAttribute' and 'Node' are not identical.
6021 interface AssertEntry extends ImportAttribute {
~~~~~~~~~~~