-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
π Search Terms
"isolatedDeclarations", "function return type", "exported variable"
π Version & Regression Information
- This changed between versions 5.6.3 and 5.7.3
β― Playground Link
π» 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.
robpalmeCopilot
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases