Skip to content

Type errors when using TypeScript 5.4 #1513

@OliverJAsh

Description

@OliverJAsh

Describe the bug

Version: 21.0.1

To Reproduce

{
    "compilerOptions": {
        "module": "Node16",
        "strict": true,
    }
}
import * as tsMorph from 'ts-morph';
console.log(tsMorph);
{
  "dependencies": {
    "ts-morph": "^21.0.1",
    "typescript": "^5.4.2"
  }
}

Run tsc:

$ /Users/oliver/Code/typescript-playground/node_modules/.bin/tsc
node_modules/ts-morph/lib/ts-morph.d.ts:5289:127 - error TS2344: Type 'CompilerNodeToWrappedType<InstanceOf<T>["compilerNode"]>' does not satisfy the constraint 'Node<Node>'.
  Type 'SourceFile | ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration | Identifier | ... 198 more ... | Node<...>' is not assignable to type 'Node<Node>'.
    Type 'SourceFile' is not assignable to type 'Node<Node>'.
      The types returned by 'forgetDescendants()' are incompatible between these types.
        Type 'SourceFile' is not assignable to type 'CompilerNodeToWrappedType<InstanceOf<T>["compilerNode"]>'.

5289 export declare function BaseExpressionedNode<T extends Constructor<ExpressionedNodeExtensionType>, TExpression extends Node = CompilerNodeToWrappedType<InstanceOf<T>["compilerNode"]>>(Base: T): Constructor<BaseExpressionedNode<TExpression>> & T;
                                                                                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in node_modules/ts-morph/lib/ts-morph.d.ts:5289

Expected behavior

No type errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions