Skip to content

Missing function signatures in typescript.d.ts #40507

Closed
@arocheleau

Description

@arocheleau

TypeScript Version: 4.0.2

Search Terms: getMutableClone cloneNode createThrow createNew NodeFactory

Code

ts.factory.cloneNode(someNode);

Expected behavior:

The compiler should compile the code just fine without error.

Actual behavior:

The compiler signal an error saying that the cloneNode function does not exists on NodeFactory.

On ts.getMutableClone the deprecated notice says we should use factory.cloneNode instead. Unfortunately, there is no cloneNode function defined on NodeFactory according to the declaration file (typescript.d.ts).

However, if I trick the compiler with the following code, I see that a cloneNode function do exist on the object that implements the NodeFactory interface at runtime.

(ts.factory as any).cloneNode(someNode);

Related Issues:

I have seen a few deprecated notices that are a bit misleading on many functions in the ts namespace. I have not checked all functions, but to name a few:

  • createThrow says to use factory.createThrow instead of factory.createThrowStatement.
  • updateThrow says to use factory.updateThrow instead of factory.updateThrowStatement.
  • ...
  • The same goes for createNew, updateNew, createTry, updateTry

Metadata

Metadata

Assignees

Labels

APIRelates to the public API for TypeScriptFix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions