Skip to content

Commit

Permalink
TypeScript 5.3 (#2617)
Browse files Browse the repository at this point in the history
- Bumps `typescript` and `ts-expose-internals` to v5.3.3
- Removes the test diagnostic for `noSuperProperty` as the compiler
catches this now (microsoft/TypeScript/pull/54056)
- Make 1:1 changes for methods and fields
- Handles the `NoSubstitutionTemplateLiteral` node from
microsoft/TypeScript/pull/55930

Please take a look at the module resolution change. I'm not sure if this
will have downstream effects that I couldn't catch in testing.

Closes #2610

---------

Co-authored-by: Osyris <osyrisrblx@gmail.com>
  • Loading branch information
LouieK22 and osyrisrblx committed Feb 14, 2024
1 parent b6a50d1 commit 2c422eb
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 34 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"fs-extra": "^11.2.0",
"kleur": "^4.1.5",
"resolve": "^1.22.6",
"typescript": "=5.2.2",
"typescript": "=5.3.3",
"yargs": "^17.7.2"
},
"devDependencies": {
Expand All @@ -64,7 +64,7 @@
"@types/node": "^20.11.17",
"@types/prompts": "^2.4.9",
"@types/resolve": "^1.20.6",
"@types/ts-expose-internals": "npm:ts-expose-internals@=5.2.2",
"@types/ts-expose-internals": "npm:ts-expose-internals@=5.3.3",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
Expand Down
6 changes: 3 additions & 3 deletions src/Project/transformers/builtin/transformPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const transformPaths = (context: ts.TransformationContext) => (sourceFile
return ts.factory.updateImportTypeNode(
node,
fileArgument,
node.assertions,
node.attributes,
node.qualifier,
node.typeArguments,
node.isTypeOf,
Expand Down Expand Up @@ -277,7 +277,7 @@ export const transformPaths = (context: ts.TransformationContext) => (sourceFile
node.isTypeOnly,
node.exportClause,
fileLiteral,
node.assertClause,
node.attributes,
);
}

Expand All @@ -289,7 +289,7 @@ export const transformPaths = (context: ts.TransformationContext) => (sourceFile
node.isTypeOnly,
node.exportClause,
fileLiteral,
node.assertClause,
node.attributes,
)
: undefined;
}
Expand Down
1 change: 0 additions & 1 deletion src/Shared/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export const errors = {
noGlobalThis: error("`globalThis` is not supported!"),
noArguments: error("`arguments` is not supported!"),
noPrototype: error("`prototype` is not supported!"),
noSuperProperty: error("super properties are not supported!"),
noRobloxSymbolInstanceof: error(
"The `instanceof` operator can only be used on roblox-ts classes!",
suggestion('Use `typeIs(myThing, "TypeToCheck") instead'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import luau from "@roblox-ts/luau-ast";
import { errors } from "Shared/diagnostics";
import { TransformState } from "TSTransformer";
import { DiagnosticService } from "TSTransformer/classes/DiagnosticService";
import { transformOptionalChain } from "TSTransformer/nodes/transformOptionalChain";
import { addIndexDiagnostics } from "TSTransformer/util/addIndexDiagnostics";
import { convertToIndexableExpression } from "TSTransformer/util/convertToIndexableExpression";
Expand Down Expand Up @@ -36,10 +34,6 @@ export function transformPropertyAccessExpressionInner(
}

export function transformPropertyAccessExpression(state: TransformState, node: ts.PropertyAccessExpression) {
if (ts.isSuperProperty(node)) {
DiagnosticService.addDiagnostic(errors.noSuperProperty(node));
}

const constantValue = getConstantValueLiteral(state, node);
if (constantValue) {
return constantValue;
Expand Down
2 changes: 1 addition & 1 deletion src/TSTransformer/util/binding/objectAccessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const objectAccessor = (
expression: parentId,
index: addOneIfArrayType(state, type, transformExpression(state, name.expression)),
});
} else if (ts.isNumericLiteral(name) || ts.isStringLiteral(name)) {
} else if (ts.isNumericLiteral(name) || ts.isStringLiteral(name) || ts.isNoSubstitutionTemplateLiteral(name)) {
return luau.create(luau.SyntaxKind.ComputedIndexExpression, {
expression: parentId,
index: transformExpression(state, name),
Expand Down
6 changes: 3 additions & 3 deletions src/TSTransformer/util/getSourceFileFromModuleSpecifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export function getSourceFileFromModuleSpecifier(state: TransformState, moduleSp
if (declaration && ts.isModuleDeclaration(declaration) && ts.isStringLiteralLike(declaration.name)) {
const sourceFile = moduleSpecifier.getSourceFile();
const mode = ts.getModeForUsageLocation(sourceFile, declaration.name);
const resolvedModuleInfo = ts.getResolvedModule(sourceFile, declaration.name.text, mode);
if (resolvedModuleInfo) {
return state.program.getSourceFile(resolvedModuleInfo.resolvedFileName);
const resolvedModuleInfo = state.program.getResolvedModule(sourceFile, declaration.name.text, mode);
if (resolvedModuleInfo && resolvedModuleInfo.resolvedModule) {
return state.program.getSourceFile(resolvedModuleInfo.resolvedModule.resolvedFileName);
}
}

Expand Down
10 changes: 0 additions & 10 deletions tests/src/diagnostics/noSuperProperty.ts

This file was deleted.

13 changes: 13 additions & 0 deletions tests/src/tests/object.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,19 @@ export = () => {
expect(c[9]).to.equal(1);
});

it("should support template literal indexes without substitution", () => {
const obj = {
data: 55,
thing: "hello"
}

const a = obj[`data`]
const b = obj[`thing`]

expect(a).to.equal(55)
expect(b).to.equal("hello")
})

it("should support composing objects with methods and callbacks", () => {
interface Numerable {
n: number;
Expand Down

0 comments on commit 2c422eb

Please sign in to comment.