mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Merge pull request #9042 from Microsoft/ES6ModulesES5Target
Fix #6319: Add support for `--t: es5` and `--m es6`
This commit is contained in:
@@ -635,10 +635,6 @@
|
||||
"category": "Error",
|
||||
"code": 1203
|
||||
},
|
||||
"Cannot compile modules into 'es2015' when targeting 'ES5' or lower.": {
|
||||
"category": "Error",
|
||||
"code": 1204
|
||||
},
|
||||
"Decorators are not valid here.": {
|
||||
"category": "Error",
|
||||
"code": 1206
|
||||
|
||||
@@ -5613,7 +5613,11 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
function emitClassLikeDeclarationBelowES6(node: ClassLikeDeclaration) {
|
||||
const isES6ExportedClass = isES6ExportedDeclaration(node);
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
if (isES6ExportedClass && !(node.flags & NodeFlags.Default)) {
|
||||
write("export ");
|
||||
}
|
||||
// source file level classes in system modules are hoisted so 'var's for them are already defined
|
||||
if (!shouldHoistDeclarationInSystemJsModule(node)) {
|
||||
write("var ");
|
||||
@@ -5683,9 +5687,15 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
emitEnd(node);
|
||||
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
if (node.kind === SyntaxKind.ClassDeclaration && !isES6ExportedClass) {
|
||||
emitExportMemberAssignment(<ClassDeclaration>node);
|
||||
}
|
||||
else if (isES6ExportedClass && (node.flags & NodeFlags.Default)) {
|
||||
writeLine();
|
||||
write("export default ");
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
|
||||
function emitClassMemberPrefix(node: ClassLikeDeclaration, member: Node) {
|
||||
|
||||
@@ -2160,11 +2160,6 @@ namespace ts {
|
||||
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
|
||||
}
|
||||
|
||||
// Cannot specify module gen target of es6 when below es6
|
||||
if (options.module === ModuleKind.ES6 && languageVersion < ScriptTarget.ES6) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
|
||||
}
|
||||
|
||||
// Cannot specify module gen that isn't amd or system with --out
|
||||
if (outFile) {
|
||||
if (options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) {
|
||||
|
||||
Reference in New Issue
Block a user