Skip to content

Commit eb8340b

Browse files
committed
fix: support TypeScriptToLua v0.30.0 and later
Dropped support for versions < 0.19.0.
1 parent d0a3b34 commit eb8340b

File tree

3 files changed

+691
-347
lines changed

3 files changed

+691
-347
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@
3838
"mock-require": "^3.0.3",
3939
"resolve-from": "^5.0.0",
4040
"resolve-global": "^1.0.0",
41-
"tslib": "^1.9.3",
42-
"typescript-to-lua": "^0.20.0"
41+
"tslib": "^2.0.0",
42+
"typescript-to-lua": "^0.34.0"
4343
},
4444
"devDependencies": {
45-
"@ark120202/eslint-config": "^1.1.0",
46-
"@ark120202/typescript-config": "^2.0.0",
45+
"@ark120202/eslint-config": "^2.3.0",
46+
"@ark120202/typescript-config": "^2.1.0",
4747
"@types/mock-require": "^2.0.0",
48-
"@types/node": "^12.0.2",
49-
"eslint": "^5.16.0",
48+
"@types/node": "^14.0.23",
49+
"eslint": "^6.8.0",
5050
"npm-run-all": "^4.1.5",
51-
"prettier": "^1.17.1",
52-
"typescript": "^3.4.5"
51+
"prettier": "^1.19.1",
52+
"typescript": "^3.9.6"
5353
},
5454
"engines": {
5555
"node": ">=10"

src/index.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,27 +80,19 @@ class TSTLPlugin {
8080
program: tsserverlibrary.Program,
8181
sourceFile: tsserverlibrary.SourceFile,
8282
) {
83-
if (this.parsedCommandLine != null && this.parsedCommandLine.raw.tstl != null) {
84-
Object.assign(program.getCompilerOptions(), this.parsedCommandLine.options);
83+
if (this.parsedCommandLine?.raw.tstl != null) {
84+
const programOptions = program.getCompilerOptions();
85+
Object.assign(programOptions, this.parsedCommandLine.options);
86+
programOptions.noEmit = true;
87+
programOptions.noEmitOnError = false;
88+
programOptions.declaration = false;
89+
programOptions.declarationMap = false;
90+
programOptions.emitDeclarationOnly = false;
8591

86-
const transformer = new this.tstl.LuaTransformer(program);
8792
try {
88-
transformer.transformSourceFile(sourceFile);
93+
const { diagnostics } = this.tstl.transpile({ program, sourceFiles: [sourceFile] });
94+
return diagnostics;
8995
} catch (error) {
90-
if (error instanceof this.tstl.TranspileError) {
91-
const diagnostic: tsserverlibrary.Diagnostic = {
92-
category: this.ts.DiagnosticCategory.Error,
93-
code: 0,
94-
file: error.node.getSourceFile(),
95-
start: error.node.getStart(),
96-
length: error.node.getWidth(),
97-
messageText: error.message,
98-
source: 'typescript-to-lua',
99-
};
100-
101-
return [diagnostic];
102-
}
103-
10496
this.log(`Error during transpilation: ${error.stack}`);
10597
}
10698
}

0 commit comments

Comments
 (0)