mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Process ES6 imports when creating program
This commit is contained in:
parent
36c9cf09e6
commit
35583e6694
@ -274,13 +274,26 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getImportedModuleName(node: Node): StringLiteralExpression {
|
||||
if (node.kind === SyntaxKind.ImportDeclaration) {
|
||||
return (<ImportDeclaration>node).moduleSpecifier;
|
||||
}
|
||||
if (node.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
var reference = (<ImportEqualsDeclaration>node).moduleReference;
|
||||
if (reference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
var expr = (<ExternalModuleReference>reference).expression;
|
||||
if (expr && expr.kind === SyntaxKind.StringLiteral) {
|
||||
return <StringLiteralExpression>expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function processImportedModules(file: SourceFile, basePath: string) {
|
||||
forEach(file.statements, node => {
|
||||
if (isExternalModuleImportEqualsDeclaration(node) &&
|
||||
getExternalModuleImportEqualsDeclarationExpression(node).kind === SyntaxKind.StringLiteral) {
|
||||
|
||||
var nameLiteral = <LiteralExpression>getExternalModuleImportEqualsDeclarationExpression(node);
|
||||
var moduleName = nameLiteral.text;
|
||||
if (node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
var nameLiteral = getImportedModuleName(node);
|
||||
var moduleName = nameLiteral && nameLiteral.text;
|
||||
if (moduleName) {
|
||||
var searchPath = basePath;
|
||||
while (true) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user