-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Convert a TypeScript declare function with a body into a function. #12046
Description
Bug Report
- I would like to work on a fix!
Current behavior
Convert a TypeScript declare function with a body into a function.
Output:
"use strict";
function foo() {}Input Code
declare function foo() {}Expected behavior
It should throw an error like tsc(TypeScript Playground). And it should support errorRecovery.
Also babel/parser should return a node of TSDeclareFunction instead of FunctionDeclaration(declare: true).
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
- Filename:
babel.config.js
{
"presets": ["@babel/preset-typescript"]
}Environment
I don't think environment information is needed because this issue is simple, but I will provide it if it is needed for you guys.
Possible Solution
Additional context
While working in Prettier, I notice that declare disappears. (Prettier Playground link)
It is possible to fix this issue on Prettier side, but I think this is the parser's responsibility.