Skip to content

Added support for importequals declaration - #598

Merged
Perryvw merged 7 commits into
masterfrom
feature/importequalsdeclaration
May 27, 2019
Merged

Added support for importequals declaration#598
Perryvw merged 7 commits into
masterfrom
feature/importequalsdeclaration

Conversation

@Perryvw

@Perryvw Perryvw commented May 25, 2019

Copy link
Copy Markdown
Member

Closes #587

@Perryvw

Perryvw commented May 25, 2019

Copy link
Copy Markdown
Member Author

I feel like there has to be a better way to do transformers.ts:503, but I don't know how.

@ark120202 ark120202 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also probably should have special handling for require call, like type checker does, or we should disallow all module targets except es6 and esnext

Comment thread src/LuaTransformer.ts Outdated
Comment thread src/LuaTransformer.ts Outdated
}

public transformQualifiedName(qualifiedName: ts.QualifiedName): ExpressionVisitResult {
const right = this.transformIdentifier(qualifiedName.right);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const right = this.transformIdentifier(qualifiedName.right);
const right = this.transformIdentifierExpression(qualifiedName.right);

Right now there's no much difference, but still it should make more sense and also be consistent with regular variable declaration.

Comment thread src/LuaTransformer.ts Outdated
public transformEntityName(entityName: ts.EntityName): ExpressionVisitResult {
return ts.isQualifiedName(entityName)
? this.transformQualifiedName(entityName)
: this.transformIdentifier(entityName);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
: this.transformIdentifier(entityName);
: this.transformIdentifierExpression(entityName);

Comment thread src/LuaTransformer.ts Outdated
@ark120202

Copy link
Copy Markdown
Contributor

Since imports are transformed into regular vars they are also supposed to be hoisted

@Perryvw
Perryvw requested a review from tomblind May 26, 2019 15:19
Comment thread src/LuaTransformer.ts Outdated
public transformExternalModuleReference(
externalModuleReference: ts.ExternalModuleReference
): ExpressionVisitResult {
return this.transformExpression(externalModuleReference.expression);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be wrapped in a require? Right now,

import foo = require("./bar");

transpiles to:

local foo = "./bar"

@Perryvw
Perryvw merged commit 8a7b31b into master May 27, 2019
@Perryvw
Perryvw deleted the feature/importequalsdeclaration branch May 27, 2019 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsupported Statement kind: ImportEqualsDeclaration

3 participants