mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 11:24:49 -05:00
Merge branch 'master' into typeAssertionInitializers
This commit is contained in:
@@ -8584,6 +8584,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function narrowTypeByEquality(type: Type, operator: SyntaxKind, value: Expression, assumeTrue: boolean): Type {
|
||||
if (type.flags & TypeFlags.Any) {
|
||||
return type;
|
||||
}
|
||||
if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) {
|
||||
assumeTrue = !assumeTrue;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,9 @@ const _super = (function (geti, seti) {
|
||||
|
||||
// Emit helpers from all the files
|
||||
if (isBundledEmit && moduleKind) {
|
||||
forEach(sourceFiles, emitEmitHelpers);
|
||||
for (const sourceFile of sourceFiles) {
|
||||
emitEmitHelpers(sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Print each transformed source file.
|
||||
|
||||
@@ -541,7 +541,7 @@ namespace ts {
|
||||
*
|
||||
* @param node A ClassDeclaration node.
|
||||
*/
|
||||
function visitClassDeclaration(node: ClassDeclaration): Statement {
|
||||
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
|
||||
// [source]
|
||||
// class C { }
|
||||
//
|
||||
@@ -552,8 +552,17 @@ namespace ts {
|
||||
// return C;
|
||||
// }());
|
||||
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
const isExported = modifierFlags & ModifierFlags.Export;
|
||||
const isDefault = modifierFlags & ModifierFlags.Default;
|
||||
|
||||
// Add an `export` modifier to the statement if needed (for `--target es5 --module es6`)
|
||||
const modifiers = isExported && !isDefault
|
||||
? filter(node.modifiers, isExportModifier)
|
||||
: undefined;
|
||||
|
||||
const statement = createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
modifiers,
|
||||
createVariableDeclarationList([
|
||||
createVariableDeclaration(
|
||||
getDeclarationName(node, /*allowComments*/ true),
|
||||
@@ -566,9 +575,26 @@ namespace ts {
|
||||
|
||||
setOriginalNode(statement, node);
|
||||
startOnNewLine(statement);
|
||||
|
||||
// Add an `export default` statement for default exports (for `--target es5 --module es6`)
|
||||
if (isExported && isDefault) {
|
||||
const statements: Statement[] = [statement];
|
||||
statements.push(createExportAssignment(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*isExportEquals*/ false,
|
||||
getDeclarationName(node, /*allowComments*/ false)
|
||||
));
|
||||
return statements;
|
||||
}
|
||||
|
||||
return statement;
|
||||
}
|
||||
|
||||
function isExportModifier(node: Modifier) {
|
||||
return node.kind === SyntaxKind.ExportKeyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a ClassExpression and transforms it into an expression.
|
||||
*
|
||||
|
||||
@@ -705,7 +705,7 @@ namespace ts {
|
||||
createFunctionDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
node.asteriskToken,
|
||||
name,
|
||||
/*typeParameters*/ undefined,
|
||||
node.parameters,
|
||||
|
||||
Reference in New Issue
Block a user