-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.7.2, 2.8.0-dev.20180228
Search Terms:
Code
import * as ts from 'typescript';
const sourceFile = ts.createSourceFile('import-foo.ts', "import {foo} from 'foo';", ts.ScriptTarget.ESNext);
ts.createPrinter().printFile(sourceFile); // works as expected
ts.createPrinter({removeComments: true}).printFile(sourceFile); // throwsExpected behavior:
No exception
Actual behavior:
This happens because ImportClause.name is undefined. Also note that ImportClause.namedBindings could also be undefined and there is no check for that.
TypeError: Cannot read property 'kind' of undefined
at pipelineEmitUnspecified (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:71850:29)
at pipelineEmitWithHint (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:71831:50)
at pipelineEmitWithSourceMap (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:71822:17)
at emitNodeWithComments (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:69263:17)
at pipelineEmitWithComments (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:71811:17)
at pipelineEmitWithNotification (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:71805:17)
at emit (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:71792:13)
at emitImportClause (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:73228:13)
at pipelineEmitUnspecified (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:72034:28)
at pipelineEmitWithHint (/home/klaus/code/wotan/node_modules/typescript/lib/typescript.js:71831:50)
Playground Link:
Related Issues:
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue