diff --git a/CHANGELOG.md b/CHANGELOG.md index 831cdc183..4e2cc02ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## Unreleased + + + +- 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: + - Importing a non-module using `import "./file"` produced a TS2307 error [#35973](https://github.com/microsoft/TypeScript/issues/35973) + - TypeScript now tries to find a call signature even in presence of type errors (#36665)(https://github.com/microsoft/TypeScript/pull/36665): + ```ts + function foo(this: void, x: string) {} + foo(1); + ``` + ```lua + -- 3.8 + foo(nil, 1) + -- 3.9 + foo(1) + ``` + ## 0.33.0 - Added support for nullish coalescing `A ?? B`. diff --git a/package-lock.json b/package-lock.json index a55b48f1d..a8e0102ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5629,9 +5629,9 @@ } }, "typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", - "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==" + "version": "3.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.2.tgz", + "integrity": "sha512-q2ktq4n/uLuNNShyayit+DTobV2ApPEo/6so68JaD5ojvc/6GClBipedB9zNWYxRSAlZXAe405Rlijzl6qDiSw==" }, "union-value": { "version": "1.0.1", diff --git a/package.json b/package.json index 6d41b4235..4992ba80a 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "dependencies": { "resolve": "^1.15.1", "source-map": "^0.7.3", - "typescript": "^3.8.3" + "typescript": "^3.9.2" }, "devDependencies": { "@types/fs-extra": "^8.1.0", diff --git a/test/unit/assignments.spec.ts b/test/unit/assignments.spec.ts index 178d72bab..02e1a3b9b 100644 --- a/test/unit/assignments.spec.ts +++ b/test/unit/assignments.spec.ts @@ -12,9 +12,7 @@ test.each(["const", "let"])("%s declaration not top-level is not global", declar }); test.each(["const", "let"])("top-level %s declaration is global", declarationKind => { - // TODO [typescript@>=3.9]: Remove `@ts-ignore` comments before module imports util.testBundle` - // @ts-ignore import './a'; export const result = foo; ` diff --git a/test/unit/builtins/array.spec.ts b/test/unit/builtins/array.spec.ts index 35294be6d..7525513a7 100644 --- a/test/unit/builtins/array.spec.ts +++ b/test/unit/builtins/array.spec.ts @@ -570,7 +570,6 @@ describe.each(["reduce", "reduceRight"])("array.%s", reduce => { const genericChecks = [ "function generic(array: T)", "function generic(array: T)", - "function generic(array: T[])", "type ArrayType = number[]; function generic(array: T)", "function generic(array: T & {})", "function generic(array: T)", diff --git a/test/unit/classes/classes.spec.ts b/test/unit/classes/classes.spec.ts index 6bf2fc85f..52bcdd0fc 100644 --- a/test/unit/classes/classes.spec.ts +++ b/test/unit/classes/classes.spec.ts @@ -772,7 +772,7 @@ test("default exported name class has correct name property", () => { util.testModule` export default class Test { static method() { return true; } } ` - .setReturnExport("default.name") + .setReturnExport("default", "name") .expectToMatchJsResult(); }); @@ -780,7 +780,7 @@ test("default exported anonymous class has 'default' name property", () => { util.testModule` export default class { static method() { return true; } } ` - .setReturnExport("default.name") + .setReturnExport("default", "name") .expectToEqual("default"); }); diff --git a/test/unit/classes/decorators.spec.ts b/test/unit/classes/decorators.spec.ts index ad77a3a11..cba245c1f 100644 --- a/test/unit/classes/decorators.spec.ts +++ b/test/unit/classes/decorators.spec.ts @@ -114,14 +114,15 @@ test("Throws error if decorator function has void context", () => { test("Exported class decorator", () => { util.testModule` - function decorator(c: T): T { - c.bar = "foobar"; - return c; + function decorator any>(Class: T): T { + return class extends Class { + public bar = "foobar"; + }; } @decorator export class Foo {} ` - .setReturnExport("Foo.bar") + .setReturnExport("Foo", "bar") .expectToMatchJsResult(); }); diff --git a/test/unit/functions/functions.spec.ts b/test/unit/functions/functions.spec.ts index 2f2f3b212..73549d918 100644 --- a/test/unit/functions/functions.spec.ts +++ b/test/unit/functions/functions.spec.ts @@ -504,9 +504,7 @@ test("missing declaration name", () => { }); test("top-level function declaration is global", () => { - // TODO [typescript@>=3.9]: Remove `@ts-ignore` comments before module imports util.testBundle` - // @ts-ignore import './a'; export const result = foo(); ` diff --git a/test/unit/identifiers.spec.ts b/test/unit/identifiers.spec.ts index 27046c81b..ba2bcd8a0 100644 --- a/test/unit/identifiers.spec.ts +++ b/test/unit/identifiers.spec.ts @@ -194,9 +194,10 @@ test.each(validTsInvalidLuaNames)("class with invalid lua name has correct name test.each(validTsInvalidLuaNames)("decorated class with invalid lua name", name => { util.testFunction` - function decorator(c: T): T { - c.bar = "foobar"; - return c; + function decorator any>(Class: T): T { + return class extends Class { + public bar = "foobar"; + }; } @decorator @@ -206,17 +207,18 @@ test.each(validTsInvalidLuaNames)("decorated class with invalid lua name", name }); test.each(validTsInvalidLuaNames)("exported decorated class with invalid lua name", name => { - const code = ` - function decorator(c: T): T { - c.bar = "foobar"; - return c; + util.testModule` + function decorator any>(Class: T): T { + return class extends Class { + public bar = "foobar"; + }; } @decorator - export class ${name} {}`; - - const lua = util.transpileString(code); - expect(util.executeLua(`return (function() ${lua} end)()["${name}"].bar`)).toBe("foobar"); + export class ${name} {} + ` + .setReturnExport(name, "bar") + .expectToMatchJsResult(); }); describe("lua keyword as identifier doesn't interfere with lua's value", () => { @@ -782,7 +784,7 @@ test("lua built-in as in constructor assignment", () => { class A { constructor(public error: string){} } - + export const result = new A("42").error; `.expectToMatchJsResult(); }); diff --git a/test/unit/namespaces.spec.ts b/test/unit/namespaces.spec.ts index a745e1383..159fb8534 100644 --- a/test/unit/namespaces.spec.ts +++ b/test/unit/namespaces.spec.ts @@ -94,11 +94,8 @@ test("namespace merging across files", () => { } `; - // TODO [typescript@>=3.9]: Remove `@ts-ignore` comments before module imports util.testBundle` - // @ts-ignore import './a'; - // @ts-ignore import './b'; export const result = NS.Inner; diff --git a/test/util.ts b/test/util.ts index 1b30c5105..a24ce29a1 100644 --- a/test/util.ts +++ b/test/util.ts @@ -431,9 +431,9 @@ class BundleTestBuilder extends AccessorTestBuilder { } class ModuleTestBuilder extends AccessorTestBuilder { - public setReturnExport(name: string): this { + public setReturnExport(...names: string[]): this { expect(this.hasProgram).toBe(false); - this.accessor = `.${name}`; + this.accessor = names.map(n => `[${tstl.escapeString(n)}]`).join(""); return this; } }