Skip to content

Commit 590e071

Browse files
committed
upgrade to TS 6.0 initial attempt
1 parent 57459c6 commit 590e071

File tree

9 files changed

+544
-289
lines changed

9 files changed

+544
-289
lines changed

package-lock.json

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

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint:prettier": "prettier --check . || (echo 'Run `npm run fix:prettier` to fix it.' && exit 1)",
3232
"lint:eslint": "eslint .",
3333
"fix:prettier": "prettier --write .",
34-
"check:language-extensions": "tsc --strict language-extensions/index.d.ts",
34+
"check:language-extensions": "tsc --strict language-extensions/index.d.ts --ignoreConfig",
3535
"preversion": "npm run build && npm test",
3636
"postversion": "git push && git push --tags"
3737
},
@@ -42,20 +42,20 @@
4242
"node": ">=16.10.0"
4343
},
4444
"peerDependencies": {
45-
"typescript": "5.9.3"
45+
"typescript": "6.0.2"
4646
},
4747
"dependencies": {
4848
"@typescript-to-lua/language-extensions": "1.19.0",
4949
"enhanced-resolve": "5.8.2",
50-
"picomatch": "^2.3.1",
50+
"picomatch": "^2.3.2",
5151
"resolve": "^1.15.1",
5252
"source-map": "^0.7.3"
5353
},
5454
"devDependencies": {
5555
"@types/fs-extra": "^8.1.0",
5656
"@types/glob": "^7.2.0",
5757
"@types/jest": "^27.5.2",
58-
"@types/node": "^22.10.0",
58+
"@types/node": "^22.19.15",
5959
"@types/picomatch": "^2.3.0",
6060
"@types/resolve": "1.14.0",
6161
"eslint": "^9.22.0",
@@ -69,7 +69,7 @@
6969
"prettier": "^2.8.8",
7070
"ts-jest": "^29.2.5",
7171
"ts-node": "^10.9.2",
72-
"typescript": "5.9.3",
72+
"typescript": "6.0.2",
7373
"typescript-eslint": "^8.46.3"
7474
}
7575
}

src/transpilation/resolve.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface ResolutionResult {
2727
}
2828

2929
class ResolutionContext {
30-
private noResolvePaths: picomatch.Matcher[];
30+
private noResolvePaths: RegExp[];
3131

3232
public diagnostics: ts.Diagnostic[] = [];
3333
public resolvedFiles = new Map<string, ProcessedFile>();
@@ -39,7 +39,7 @@ class ResolutionContext {
3939
private readonly plugins: Plugin[]
4040
) {
4141
const unique = [...new Set(options.noResolvePaths)];
42-
const matchers = unique.map(x => picomatch(x));
42+
const matchers = unique.map(x => picomatch.makeRe(x));
4343
this.noResolvePaths = matchers;
4444
}
4545

@@ -73,7 +73,7 @@ class ResolutionContext {
7373
return;
7474
}
7575

76-
if (this.noResolvePaths.find(isMatch => isMatch(required.requirePath))) {
76+
if (this.noResolvePaths.find(isMatch => isMatch.test(required.requirePath))) {
7777
if (this.options.tstlVerbose) {
7878
console.log(
7979
`Skipping module resolution of ${required.requirePath} as it is in the tsconfig noResolvePaths.`

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function cast<TOriginal, TCast extends TOriginal>(
7777
}
7878

7979
export function assert(value: any, message?: string | Error): asserts value {
80-
nativeAssert(value, message);
80+
nativeAssert.ok(value, message);
8181
}
8282

8383
export function assertNever(_value: never): never {

test/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare global {
1313

1414
expect.extend({
1515
toHaveDiagnostics(diagnostics: ts.Diagnostic[], expected?: number[]): jest.CustomMatcherResult {
16-
assert(Array.isArray(diagnostics));
16+
assert.ok(Array.isArray(diagnostics));
1717
// @ts-ignore
1818
const matcherHint = this.utils.matcherHint("toHaveDiagnostics", undefined, "", this);
1919

test/transpile/module-resolution.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ test("module resolution uses baseURL to resolve imported files", () => {
598598
return { baz = function() return "baz" end }
599599
`
600600
)
601-
.setOptions({ baseUrl: "./myproject/mydeps" })
601+
.setOptions({ baseUrl: "./myproject/mydeps", ignoreDeprecations: "6.0" })
602602
.expectToEqual({
603603
fooResult: "foo",
604604
barResult: "bar",

test/unit/optionalChaining.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ describe("optional chaining function calls", () => {
342342
`
343343
.setOptions({
344344
strict,
345-
target: ScriptTarget.ES5,
346345
})
347346
.expectToMatchJsResult();
348347
});

test/util.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function getLuaBindingsForVersion(target: tstl.LuaTarget): { lauxlib: LauxLib; l
5151
}
5252

5353
export function assert(value: any, message?: string | Error): asserts value {
54-
nativeAssert(value, message);
54+
nativeAssert.ok(value, message);
5555
}
5656

5757
export const formatCode = (...values: unknown[]) => values.map(e => stringify(e)).join(", ");
@@ -92,17 +92,15 @@ export function expectEachVersionExceptJit<T>(
9292
};
9393
}
9494

95-
const memoize: MethodDecorator = (_target, _propertyKey, descriptor) => {
96-
const originalFunction = descriptor.value as any;
95+
const memoize = (originalFunction: any) => {
9796
const memoized = new WeakMap();
98-
descriptor.value = function (this: any, ...args: any[]): any {
97+
return function (this: any, ...args: any[]): any {
9998
if (!memoized.has(this)) {
10099
memoized.set(this, originalFunction.apply(this, args));
101100
}
102101

103102
return memoized.get(this);
104-
} as any;
105-
return descriptor;
103+
};
106104
};
107105

108106
export class ExecutionError extends Error {
@@ -158,12 +156,13 @@ export abstract class TestBuilder {
158156
}
159157

160158
protected options: tstl.CompilerOptions = {
159+
strict: false,
161160
luaTarget: tstl.LuaTarget.Lua55,
162161
noHeader: true,
163162
skipLibCheck: true,
164163
target: ts.ScriptTarget.ES2017,
165164
lib: ["lib.esnext.d.ts"],
166-
moduleResolution: ts.ModuleResolutionKind.Node10,
165+
moduleResolution: ts.ModuleResolutionKind.Bundler,
167166
resolveJsonModule: true,
168167
sourceMap: true,
169168
};

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"lib": ["es2019"],
55
"types": ["node"],
66
"module": "commonjs",
7-
"experimentalDecorators": true,
87

98
"rootDir": "src",
109
"outDir": "dist",

0 commit comments

Comments
 (0)