Use the module's fileName as its name

For now we will use the module's fileName as its name.  This matches
the ECMAScript semantics, however, we will eventually want to do a pass
to normalize these names into more "Mu-friendly" module names.
This commit is contained in:
joeduffy 2017-01-10 08:14:02 -08:00
parent 641fb5bd21
commit a2b02381fc

View file

@ -128,11 +128,13 @@ function transformSourceFile(node: ts.SourceFile): ast.Module {
members[initializer.name.ident] = initializer; members[initializer.name.ident] = initializer;
} }
// TODO(joe): we are using the fileName as the module name; this will lead to pretty hokey names, and we will
// need to do a pass over this to massage it. To do this properly, we'll need some path "context".
return copyLocation(node, { return copyLocation(node, {
kind: ast.moduleKind, kind: ast.moduleKind,
name: <ast.Identifier>{ name: <ast.Identifier>{
kind: ast.identifierKind, kind: ast.identifierKind,
ident: node.moduleName, ident: node.fileName,
}, },
members: members, members: members,
}); });
@ -419,7 +421,7 @@ function transformLocalVariableStatement(node: ts.VariableStatement): ast.Statem
if (variable.initializer) { if (variable.initializer) {
statements.push(makeVariableInitializer(variable)); statements.push(makeVariableInitializer(variable));
} }
}; }
if (statements.length === 1) { if (statements.length === 1) {
return statements[0]; return statements[0];
} }