Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## Unreleased

<!-- TODO: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html doesn't seem to work now -->

- 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`.
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions test/unit/assignments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
`
Expand Down
1 change: 0 additions & 1 deletion test/unit/builtins/array.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ describe.each(["reduce", "reduceRight"])("array.%s", reduce => {
const genericChecks = [
"function generic<T extends number[]>(array: T)",
"function generic<T extends [...number[]]>(array: T)",
"function generic<T extends any>(array: T[])",
"type ArrayType = number[]; function generic<T extends ArrayType>(array: T)",
"function generic<T extends number[]>(array: T & {})",
"function generic<T extends number[] & {}>(array: T)",
Expand Down
4 changes: 2 additions & 2 deletions test/unit/classes/classes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,15 @@ 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();
});

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");
});

Expand Down
9 changes: 5 additions & 4 deletions test/unit/classes/decorators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,15 @@ test("Throws error if decorator function has void context", () => {

test("Exported class decorator", () => {
util.testModule`
function decorator<T extends any>(c: T): T {
c.bar = "foobar";
return c;
function decorator<T extends new (...args: any[]) => any>(Class: T): T {
return class extends Class {
public bar = "foobar";
};
}

@decorator
export class Foo {}
`
.setReturnExport("Foo.bar")
.setReturnExport("Foo", "bar")
.expectToMatchJsResult();
});
2 changes: 0 additions & 2 deletions test/unit/functions/functions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
`
Expand Down
26 changes: 14 additions & 12 deletions test/unit/identifiers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends any>(c: T): T {
c.bar = "foobar";
return c;
function decorator<T extends new (...args: any[]) => any>(Class: T): T {
return class extends Class {
public bar = "foobar";
};
}

@decorator
Expand All @@ -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<T extends any>(c: T): T {
c.bar = "foobar";
return c;
util.testModule`
function decorator<T extends new (...args: any[]) => 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", () => {
Expand Down Expand Up @@ -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();
});
3 changes: 0 additions & 3 deletions test/unit/namespaces.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down