Closed
Description
TypeScript Version: 3.1.0-dev.20180907
Search Terms:
Error emitting function type signature.
Code
Note: This behavior is using the compiler API.
import * as ts from 'typescript';
const typeNode = ts.createVariableStatement(
[], [ts.createVariableDeclaration(
'a',
ts.createFunctionTypeNode(
[], [ts.createParameter([], [], undefined, 'hello')],
ts.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)))]);
const printer = ts.createPrinter({});
console.log(printer.printNode(
ts.EmitHint.Unspecified, typeNode,
ts.createSourceFile('', '', ts.ScriptTarget.ES5)));
Expected behavior:
Should output:
var a: (hello) => string;
Actual behavior:
var a: hello => string;
Playground Link:
Note: This behavior is using the compiler API.
Related Issues:
I couldn't find a related issue but I think the problem is an error in https://github.com/Microsoft/TypeScript/blob/master/src/compiler/emitter.ts#L2817