Skip to content

Update to TypeScript 4#914

Merged
Perryvw merged 12 commits intoTypeScriptToLua:masterfrom
hazzard993:update-typescript
Sep 14, 2020
Merged

Update to TypeScript 4#914
Perryvw merged 12 commits intoTypeScriptToLua:masterfrom
hazzard993:update-typescript

Conversation

@hazzard993
Copy link
Copy Markdown
Contributor

Fixes #912

Tried to keep changes small

Removed tests that no longer passed TypeScript's type checker

@hazzard993 hazzard993 changed the title Update to TypeScript 4.0 Update to TypeScript 4 Sep 11, 2020
@@ -47,7 +47,7 @@
"@types/node": "^13.7.7",
"@types/resolve": "1.14.0",
"@typescript-eslint/eslint-plugin": "^2.31.0",
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.

Plugin version should match the parser, otherwise some rules might handle AST incorrectly. Though if it works okay with current codebase, and there would be some rules with changed configuration format, I think it's fine to keep it that way for now. I could update it to match my base config later

`.expectToMatchJsResult();
});

test("set accessor override", () => {
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.

Could you check skipped tests tests, I think they shouldn't be relevant now too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep they were too, removed them as well

import { ScopeType, walkScopesUp } from "../utils/scope";
import { isArrayType } from "../utils/typescript";

function transformExpressionToTupleExpressions(
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.

TupleExpressions doesn't make much sense for me. Maybe transformExpressionsInReturn, and let it handle https://github.com/hazzard993/TypescriptToLua/blob/update-typescript/src/transformation/visitors/return.ts#L71-L75 too, so that both usages would be simplified to lua.createReturnStatement(transformExpressionsInReturn(...)) and const results = transformExpressionsInReturn(...)?

if (!isInTupleReturnFunction(context, node)) {
	return [context.transformExpression(statement.expression)];
}

let results: lua.Expression[];
// ...

}

export function transformFunctionBodyStatements(context: TransformationContext, body: ts.Block): lua.Statement[] {
export function transformFunctionBodyStatements(context: TransformationContext, body: ts.ConciseBody): lua.Statement[] {
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.

Statements doesn't make much sense given that now it works on expressions too. transformFunctionBodyContent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks again @ark120202!

| ts.SyntaxKind.GreaterThanGreaterThanToken
| ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken;

const compoundToAssignmentTokens: Record<ts.CompoundAssignmentOperator, CompoundAssignmentToken> = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Which CompoundAssignmentOperator do we not support now?

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.

??=, &&=, ||=

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For this PR we should either create an issue to support these compound operators later, or just revert the Partial/ | undefined changes and add them here, but then we also need some tests for them. I'm leaving it up to @hazzard993 to decide.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created #916 to complete this later

@Perryvw Perryvw merged commit 1093e8f into TypeScriptToLua:master Sep 14, 2020
@hazzard993 hazzard993 deleted the update-typescript branch September 14, 2020 07:50
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.

Feature request: typescript 4 labeled tuple support

3 participants