Skip to content

Commit 6131fa6

Browse files
authored
Upgrade TypeScript to v3.9 (#874)
1 parent 7260012 commit 6131fa6

File tree

11 files changed

+45
-32
lines changed

11 files changed

+45
-32
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
<!-- TODO: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html doesn't seem to work now -->
6+
7+
- TypeScript has been updated to 3.9. See [release notes](https://devblogs.microsoft.com/typescript/announcing-typescript-3-9/) for details. This update includes some fixes specific to our API usage:
8+
- Importing a non-module using `import "./file"` produced a TS2307 error [#35973](https://github.com/microsoft/TypeScript/issues/35973)
9+
- TypeScript now tries to find a call signature even in presence of type errors (#36665)(https://github.com/microsoft/TypeScript/pull/36665):
10+
```ts
11+
function foo(this: void, x: string) {}
12+
foo(1);
13+
```
14+
```lua
15+
-- 3.8
16+
foo(nil, 1)
17+
-- 3.9
18+
foo(1)
19+
```
20+
321
## 0.33.0
422

523
- Added support for nullish coalescing `A ?? B`.

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"dependencies": {
3939
"resolve": "^1.15.1",
4040
"source-map": "^0.7.3",
41-
"typescript": "^3.8.3"
41+
"typescript": "^3.9.2"
4242
},
4343
"devDependencies": {
4444
"@types/fs-extra": "^8.1.0",

test/unit/assignments.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ test.each(["const", "let"])("%s declaration not top-level is not global", declar
1212
});
1313

1414
test.each(["const", "let"])("top-level %s declaration is global", declarationKind => {
15-
// TODO [typescript@>=3.9]: Remove `@ts-ignore` comments before module imports
1615
util.testBundle`
17-
// @ts-ignore
1816
import './a';
1917
export const result = foo;
2018
`

test/unit/builtins/array.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ describe.each(["reduce", "reduceRight"])("array.%s", reduce => {
570570
const genericChecks = [
571571
"function generic<T extends number[]>(array: T)",
572572
"function generic<T extends [...number[]]>(array: T)",
573-
"function generic<T extends any>(array: T[])",
574573
"type ArrayType = number[]; function generic<T extends ArrayType>(array: T)",
575574
"function generic<T extends number[]>(array: T & {})",
576575
"function generic<T extends number[] & {}>(array: T)",

test/unit/classes/classes.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,15 +772,15 @@ test("default exported name class has correct name property", () => {
772772
util.testModule`
773773
export default class Test { static method() { return true; } }
774774
`
775-
.setReturnExport("default.name")
775+
.setReturnExport("default", "name")
776776
.expectToMatchJsResult();
777777
});
778778

779779
test("default exported anonymous class has 'default' name property", () => {
780780
util.testModule`
781781
export default class { static method() { return true; } }
782782
`
783-
.setReturnExport("default.name")
783+
.setReturnExport("default", "name")
784784
.expectToEqual("default");
785785
});
786786

test/unit/classes/decorators.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,15 @@ test("Throws error if decorator function has void context", () => {
114114

115115
test("Exported class decorator", () => {
116116
util.testModule`
117-
function decorator<T extends any>(c: T): T {
118-
c.bar = "foobar";
119-
return c;
117+
function decorator<T extends new (...args: any[]) => any>(Class: T): T {
118+
return class extends Class {
119+
public bar = "foobar";
120+
};
120121
}
121122
122123
@decorator
123124
export class Foo {}
124125
`
125-
.setReturnExport("Foo.bar")
126+
.setReturnExport("Foo", "bar")
126127
.expectToMatchJsResult();
127128
});

test/unit/functions/functions.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,7 @@ test("missing declaration name", () => {
504504
});
505505

506506
test("top-level function declaration is global", () => {
507-
// TODO [typescript@>=3.9]: Remove `@ts-ignore` comments before module imports
508507
util.testBundle`
509-
// @ts-ignore
510508
import './a';
511509
export const result = foo();
512510
`

test/unit/identifiers.spec.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ test.each(validTsInvalidLuaNames)("class with invalid lua name has correct name
194194

195195
test.each(validTsInvalidLuaNames)("decorated class with invalid lua name", name => {
196196
util.testFunction`
197-
function decorator<T extends any>(c: T): T {
198-
c.bar = "foobar";
199-
return c;
197+
function decorator<T extends new (...args: any[]) => any>(Class: T): T {
198+
return class extends Class {
199+
public bar = "foobar";
200+
};
200201
}
201202
202203
@decorator
@@ -206,17 +207,18 @@ test.each(validTsInvalidLuaNames)("decorated class with invalid lua name", name
206207
});
207208

208209
test.each(validTsInvalidLuaNames)("exported decorated class with invalid lua name", name => {
209-
const code = `
210-
function decorator<T extends any>(c: T): T {
211-
c.bar = "foobar";
212-
return c;
210+
util.testModule`
211+
function decorator<T extends new (...args: any[]) => any>(Class: T): T {
212+
return class extends Class {
213+
public bar = "foobar";
214+
};
213215
}
214216
215217
@decorator
216-
export class ${name} {}`;
217-
218-
const lua = util.transpileString(code);
219-
expect(util.executeLua(`return (function() ${lua} end)()["${name}"].bar`)).toBe("foobar");
218+
export class ${name} {}
219+
`
220+
.setReturnExport(name, "bar")
221+
.expectToMatchJsResult();
220222
});
221223

222224
describe("lua keyword as identifier doesn't interfere with lua's value", () => {
@@ -782,7 +784,7 @@ test("lua built-in as in constructor assignment", () => {
782784
class A {
783785
constructor(public error: string){}
784786
}
785-
787+
786788
export const result = new A("42").error;
787789
`.expectToMatchJsResult();
788790
});

test/unit/namespaces.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ test("namespace merging across files", () => {
9494
}
9595
`;
9696

97-
// TODO [typescript@>=3.9]: Remove `@ts-ignore` comments before module imports
9897
util.testBundle`
99-
// @ts-ignore
10098
import './a';
101-
// @ts-ignore
10299
import './b';
103100
104101
export const result = NS.Inner;

0 commit comments

Comments
 (0)