Skip to content

@overload Tags do not receive noImplicitAny errors on missing return types #52514

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

Closed
DanielRosenwasser opened this issue Jan 30, 2023 · 0 comments · Fixed by #52518
Closed

@overload Tags do not receive noImplicitAny errors on missing return types #52514

DanielRosenwasser opened this issue Jan 30, 2023 · 0 comments · Fixed by #52518
Assignees
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Fix Available A PR has been opened for this issue Help Wanted You can do this

Comments

@DanielRosenwasser
Copy link
Member

Playground Link

// @ts-check

/**
 * @overload
 * @param {number} x
 */

/**
 * @overload
 * @param {string} x
 */

/**
 * @param {string | number} x
 * @returns {string | number}
 */
function id(x) {
    return x;
}

export let a = id(123);
export let b = id("hello");

Here, the first two signatures of id are missing an @return/@returns tag. That means that they're implicitly any.

Under noImplicitAny, this example should issue an error on both @overload tags saying that they implicitly return the type any.

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Help Wanted You can do this Add a Flag Any problem can be solved by flags, except for the problem of having too many flags Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". labels Jan 30, 2023
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 5.0.1 milestone Jan 30, 2023
@DanielRosenwasser DanielRosenwasser added Domain: JSDoc Relates to JSDoc parsing and type generation checkJs Relates to checking JavaScript using TypeScript labels Jan 30, 2023
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Jan 30, 2023
@DanielRosenwasser DanielRosenwasser removed the Add a Flag Any problem can be solved by flags, except for the problem of having too many flags label Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Fix Available A PR has been opened for this issue Help Wanted You can do this
Projects
None yet
3 participants