TypeScript/tests/cases/fourslash/refactorConvertToEs6Module_unexported_uninitialized_var.ts
Nathan Shively-Sanders 53906f222f
containsTopLevelCommonjs:handle uninitialised vars (#27642)
Previously it assumed that all variable declarations had an initialiser,
which is not correct.
2018-10-09 13:17:54 -07:00

25 lines
543 B
TypeScript

/// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////var privateUnrelated;
////[|exports.f|] = function() {};
////privateUnrelated = 1;
////console.log(privateUnrelated);
verify.getSuggestionDiagnostics([{
message: "File is a CommonJS module; it may be converted to an ES6 module.",
code: 80001,
}]);
verify.codeFix({
description: "Convert to ES6 module",
newFileContent:
`var privateUnrelated;
export function f() {}
privateUnrelated = 1;
console.log(privateUnrelated);`,
});