🔎 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*asReactfrom'react';import{action}from'mobx';import{observer}from'mobx-react';exportconstComponent=observer(()=>{return<></>;});exportconstthing=action(function(){returnComponent;});🙁 Actual behavior
import*asReactfrom'react';import{action}from'mobx';import{observer}from'mobx-react';exportconstComponent=observer(()=>{~~~~~~~~~Variablemusthaveanexplicittypeannotationwith--isolatedDeclarations.~~~~~Functionmusthaveanexplicitreturntypeannotationwith--isolatedDeclarations.return<></>;});exportconstthing=action(function(){~~~~~Variablemusthaveanexplicittypeannotationwith--isolatedDeclarations.~~~~~~~~Functionmusthaveanexplicitreturntypeannotationwith--isolatedDeclarations.returnComponent;});🙂 Expected behavior
import*asReactfrom'react';import{action}from'mobx';import{observer}from'mobx-react';exportconstComponent=observer(()=>{~~~~~~~~~Variablemusthaveanexplicittypeannotationwith--isolatedDeclarations.return<></>;});exportconstthing=action(function(){~~~~~Variablemusthaveanexplicittypeannotationwith--isolatedDeclarations.returnComponent;});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.
🔎 Search Terms
"isolatedDeclarations", "function return type", "exported variable"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?isolatedDeclarations=true#code/JYWwDg9gTgLgBAKjgQwM5wEoFNkGN4BmUEIcA5FDvmQNwBQokscA3ivsBAHZwC+cREuRAQARgA9aDcNHhsxqLFABuSvgOKkyIiQFpKeGFLpZxTeLm6p4AYRKQuWLvAC8cBUtVQAFN4CUcC4AfKx0cHCUMACuUDwAPEFxAPRB9Lx+9CZmsnCWXNZwMAAWwFwA5oHsMJxc3gRRXBzccP6h4ZExPHYyjs5pGXRAA
💻 Code
🙁 Actual behavior
🙂 Expected behavior
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-fixto 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.