Skip to content

sourceFiles no longer added to program emit callback #12444

@tlancina

Description

@tlancina

It looks like there was possibly a small regression in cfa4388, undoing part of #7525. It seems like there was a manual merge there as well, so it's hard to see what the actual changes were.

https://github.com/Microsoft/TypeScript/blob/877e3c48156619aa934c3188d39cf912eeba3b72/src/compiler/emitter.ts#L767

Related: #7438.

TypeScript Version: 2.1.1

Code

import * as ts from 'typescript';
const files = ['index.ts']
const program = ts.createProgram(files, {});
program.emit(undefined, (path: string, data: string, writeByteOrderMark: boolean, onError: Function, sourceFiles: ts.SourceFile[]) => {
  // prints undefined on 2.1.1, 1 on earlier versions
  console.log(sourceFiles && sourceFiles.length);
});

Expected behavior: sourceFiles are added to emit callback

Actual behavior: sourceFiles are undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions