Microsoft/TypeScript

Generated d.ts includes implicit any for recursive types

Open

#55 832 ouverte le 22 sept. 2023

Voir sur GitHub
 (9 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
Domain: Declaration EmitHelp WantedPossible Improvement

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

🔎 Search Terms

recursive any noImplicitAny d.ts

🕗 Version & Regression Information

  • This is the behavior in every version I tried (3.3 through 5.2), and I reviewed the FAQ for entries about anything related to this.

⏯ Playground Link

playground link

💻 Code

const a = () => a;

🙁 Actual behavior

Any is implicitly introduced in the d.ts:

declare const a: () => any;

Note that the local type checking (not using the d.ts) correctly handles this recursive type without introducing "any", and builds fine with noImplicitAny enabled.

🙂 Expected behavior

Either generate something without implicitly introducing any, or generate an error if noImplicitAny is enabled. In this case, the below code generation for the d.ts would work:

declare const a: () => typeof a;

Additional information about the issue

No response

Guide contributeur