GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [isolatedDeclarations] function expressions as an argument to a function call that is exported are reported as needing an annotation · Issue #62085 · microsoft/TypeScript

[isolatedDeclarations] function expressions as an argument to a function call that is exported are reported as needing an annotation #62085

New issue
Copy link
New issue
Copy link
Open
Open
[isolatedDeclarations] function expressions as an argument to a function call that is exported are reported as needing an annotation#62085
Copy link
Assignees
copilot-swe-agent
Labels
Domain: flag: isolatedDeclarationsRelated to the --isolatedDeclarations compiler flagPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Backlog

Description

@bradzacher
Brad Zacher (bradzacher)
opened on Jul 17, 2025
Issue body actions

🔎 Search Terms

"isolatedDeclarations", "function return type", "exported variable"

🕗 Version & Regression Information

  • This changed between versions 5.6.3 and 5.7.3

⏯ Playground Link

https://www.typescriptlang.org/play/?isolatedDeclarations=true#code/JYWwDg9gTgLgBAKjgQwM5wEoFNkGN4BmUEIcA5FDvmQNwBQokscA3ivsBAHZwC+cREuRAQARgA9aDcNHhsxqLFABuSvgOKkyIiQFpKeGFLpZxTeLm6p4AYRKQuWLvAC8cBUtVQAFN4CUcC4AfKx0cHCUMACuUDwAPEFxAPRB9Lx+9CZmsnCWXNZwMAAWwFwA5oHsMJxc3gRRXBzccP6h4ZExPHYyjs5pGXRAA

💻 Code

import * as React from 'react';
import { action } from 'mobx';
import { observer } from 'mobx-react';

export const Component = observer(() => {
  return <></>;
});

export const thing = action(function () {
  return Component;
});

🙁 Actual behavior

import * as React from 'react';
import { action } from 'mobx';
import { observer } from 'mobx-react';

export const Component = observer(() => {
             ~~~~~~~~~ Variable must have an explicit type annotation with --isolatedDeclarations.
                                  ~~~~~ Function must have an explicit return type annotation with --isolatedDeclarations.
  return <></>;
});

export const thing = action(function () {
             ~~~~~ Variable must have an explicit type annotation with --isolatedDeclarations.
                            ~~~~~~~~ Function must have an explicit return type annotation with --isolatedDeclarations.
  return Component;
});

🙂 Expected behavior

import * as React from 'react';
import { action } from 'mobx';
import { observer } from 'mobx-react';

export const Component = observer(() => {
             ~~~~~~~~~ Variable must have an explicit type annotation with --isolatedDeclarations.
  return <></>;
});

export const thing = action(function () {
             ~~~~~ Variable must have an explicit type annotation with --isolatedDeclarations.
  return Component;
});

Additional information about the issue

The function expressions are not directly exported so they should not be reported on at all.
This is causing ts-fix to insert many unnecessary annotations when codemodding the codebase at Canva because there's no way for it to tell that annotating the variable will silence the error on the function -- so it adds both annotations.

Reacted by Rob Palmer
Reacted by Copilot

Activity

  1. KisaragiEffective commented on Jul 18, 2025

    @KisaragiEffective
    Kisaragi (KisaragiEffective)
    on Jul 18, 2025
    More actions

    Here's self-contained example based on yours:

    export declare function observer<T>(component: T): T;
    export declare function action<T>(fn: T): T;
    
    // ok
    () => 1;
    // also ok
    observer(() => 1);
    
    // error on both variable and function
    export const named = observer(() => 1);
    // also error on both variable and function
    export const thing = action(() => named);
    // error on variable, but not function
    export const thing2 = action((): typeof named => named);

    maybe changed in #59282 , according history from https://github.com/microsoft/TypeScript/blame/2778e84ed88894156e2c5a17d74a25c73cc96ffe/tests/baselines/reference/isolatedDeclarationErrors.errors.txt#L3

  2. Ryan Cavanaugh (RyanCavanaugh)
    added
    Help Wanted
    Possible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
    on Jul 21, 2025
  3. Ryan Cavanaugh (RyanCavanaugh)
    added this to the Backlog milestone on Jul 21, 2025
  4. Jake Bailey (jakebailey)
    assigned
    Copilot
    on Jul 25, 2025
  5. TypeScript Bot (typescript-bot)
    added
    Fix AvailableA PR has been opened for this issue
    on Jul 25, 2025
  6. Copilot
    added a commit that references this issue on Jul 25, 2025

    Fix isolated declarations to not flag function expressions in call ar…

    This issue will close once commit b3bebe3 is merged into the 'main' branch.
    b3bebe3
  7. Ryan Cavanaugh (RyanCavanaugh)
    added
    Domain: flag: isolatedDeclarationsRelated to the --isolatedDeclarations compiler flag
    on Oct 15, 2025
  8. Jake Bailey (jakebailey)
    removed
    Fix AvailableA PR has been opened for this issue
    on Aug 20, 2026
  9. Ryan Cavanaugh (RyanCavanaugh)
    removed
    Help Wanted
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • Copilot

Labels

Domain: flag: isolatedDeclarationsRelated to the --isolatedDeclarations compiler flagPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some cases

Type

No type

Projects

No projects

    Milestone

    • BacklogNo due date

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.