Skip to content

Commit 0aeeaef

Browse files
committed
Upgrade TypeScript to v3.6
1 parent f54cdef commit 0aeeaef

File tree

8 files changed

+60
-25
lines changed

8 files changed

+60
-25
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"types": "dist/index.d.ts",
2020
"scripts": {
2121
"build": "tsc -p tsconfig.json && npm run build-lualib",
22-
"build-lualib": "ts-node ./build_lualib.ts",
23-
"pretest": "npm run lint && ts-node --transpile-only ./build_lualib.ts",
22+
"build-lualib": "ts-node --files ./build_lualib.ts",
23+
"pretest": "npm run lint && ts-node --files --transpile-only ./build_lualib.ts",
2424
"test": "jest",
2525
"lint": "npm run lint:tslint && npm run lint:prettier",
2626
"lint:prettier": "prettier --check \"**/*.{js,ts,yml,json,md}\" || (echo 'Run `npm run fix:prettier` to fix it.' && exit 1)",
@@ -41,7 +41,7 @@
4141
"dependencies": {
4242
"resolve": "^1.11.0",
4343
"source-map": "^0.7.3",
44-
"typescript": "3.5.x"
44+
"typescript": "^3.6.2"
4545
},
4646
"devDependencies": {
4747
"@types/glob": "^7.1.1",

src/LuaTransformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4458,7 +4458,7 @@ export class LuaTransformer {
44584458
}
44594459

44604460
protected transformArguments<T extends ts.Expression>(
4461-
params: ts.NodeArray<ts.Expression> | ts.Expression[],
4461+
params: readonly ts.Expression[],
44624462
sig?: ts.Signature,
44634463
context?: T
44644464
): tstl.Expression[] {

src/TSHelper.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ export function getCustomDecorators(type: ts.Type, checker: ts.TypeChecker): Map
404404
return decMap;
405405
}
406406

407-
export function getCustomNodeDirectives(node: ts.Node): Map<DecoratorKind, Decorator> {
407+
function getCustomNodeDirectives(node: ts.Node): Map<DecoratorKind, Decorator> {
408408
const directivesMap = new Map<DecoratorKind, Decorator>();
409409

410410
ts.getJSDocTags(node).forEach(tag => {
@@ -419,10 +419,25 @@ export function getCustomNodeDirectives(node: ts.Node): Map<DecoratorKind, Decor
419419
}
420420

421421
export function getCustomFileDirectives(file: ts.SourceFile): Map<DecoratorKind, Decorator> {
422+
const directivesMap = new Map<DecoratorKind, Decorator>();
423+
422424
if (file.statements.length > 0) {
423-
return getCustomNodeDirectives(file.statements[0]);
425+
// Manually collect jsDoc because `getJSDocTags` includes tags only from closest comment
426+
const jsDoc = file.statements[0].jsDoc;
427+
if (jsDoc) {
428+
// TODO(refactor): flatMap
429+
const tags = jsDoc.reduce<ts.JSDocTag[]>((acc, x) => [...acc, ...(x.tags || [])], []);
430+
tags.forEach(tag => {
431+
const tagName = tag.tagName.text;
432+
if (Decorator.isValid(tagName)) {
433+
const dec = new Decorator(tagName, tag.comment ? tag.comment.split(" ") : []);
434+
directivesMap.set(dec.kind, dec);
435+
}
436+
});
437+
}
424438
}
425-
return new Map();
439+
440+
return directivesMap;
426441
}
427442

428443
export function getCustomSignatureDirectives(

src/typescript-internal.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as ts from "typescript";
2+
3+
declare module "typescript" {
4+
interface Statement {
5+
jsDoc?: ts.JSDoc[];
6+
}
7+
}

test/unit/decorators/luaIterator.spec.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ test("forof lua iterator destructuring with existing variables", () => {
119119
test("forof lua iterator tuple-return", () => {
120120
const code = `
121121
const arr = ["a", "b", "c"];
122-
/** @luaIterator */
123-
/** @tupleReturn */
122+
/**
123+
* @luaIterator
124+
* @tupleReturn
125+
*/
124126
interface Iter extends Iterable<[string, string]> {}
125127
function luaIter(): Iter {
126128
let i = 0;
@@ -144,8 +146,10 @@ test("forof lua iterator tuple-return", () => {
144146
test("forof lua iterator tuple-return with existing variables", () => {
145147
const code = `
146148
const arr = ["a", "b", "c"];
147-
/** @luaIterator */
148-
/** @tupleReturn */
149+
/**
150+
* @luaIterator
151+
* @tupleReturn
152+
*/
149153
interface Iter extends Iterable<[string, string]> {}
150154
function luaIter(): Iter {
151155
let i = 0;
@@ -170,8 +174,10 @@ test("forof lua iterator tuple-return with existing variables", () => {
170174

171175
test("forof lua iterator tuple-return single variable", () => {
172176
const code = `
173-
/** @luaIterator */
174-
/** @tupleReturn */
177+
/**
178+
* @luaIterator
179+
* @tupleReturn
180+
*/
175181
interface Iter extends Iterable<[string, string]> {}
176182
declare function luaIter(): Iter;
177183
for (let x of luaIter()) {}
@@ -188,8 +194,10 @@ test("forof lua iterator tuple-return single variable", () => {
188194

189195
test("forof lua iterator tuple-return single existing variable", () => {
190196
const code = `
191-
/** @luaIterator */
192-
/** @tupleReturn */
197+
/**
198+
* @luaIterator
199+
* @tupleReturn
200+
*/
193201
interface Iter extends Iterable<[string, string]> {}
194202
declare function luaIter(): Iter;
195203
let x: [string, string];
@@ -235,8 +243,10 @@ test("forof forwarded lua iterator", () => {
235243
test("forof forwarded lua iterator with tupleReturn", () => {
236244
const code = `
237245
const arr = ["a", "b", "c"];
238-
/** @luaIterator */
239-
/** @tupleReturn */
246+
/**
247+
* @luaIterator
248+
* @tupleReturn
249+
*/
240250
interface Iter extends Iterable<[string, string]> {}
241251
function luaIter(): Iter {
242252
let i = 0;

test/unit/loops.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,10 @@ describe("for...of empty destructuring", () => {
547547
test("luaIterator+tupleReturn", () => {
548548
const code = `
549549
const arr = [["a", "b"], ["c", "d"], ["e", "f"]];
550-
/** @luaIterator */
551-
/** @tupleReturn */
550+
/**
551+
* @luaIterator
552+
* @tupleReturn
553+
*/
552554
interface Iter extends Iterable<[string, string]> {}
553555
function luaIter(): Iter {
554556
let it = 0;

test/unit/tshelper.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ test("GetCustomDecorators multiple jsdoc", () => {
114114
test("GetCustomDecorators multiple default jsdoc", () => {
115115
const source = `
116116
/**
117-
* @description abc
118-
* @phantom
119-
* @compileMembersOnly */
117+
* @description abc
118+
* @phantom
119+
* @compileMembersOnly
120+
*/
120121
enum TestEnum {
121122
val1 = 0,
122123
val2 = 2,

0 commit comments

Comments
 (0)