Skip to content

Commit 392caad

Browse files
committed
Use TypeScript 3.4 readonly array literals syntax
1 parent b0b3f10 commit 392caad

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/LuaTransformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export class LuaTransformer {
208208
}
209209

210210
/** Converts an array of ts.Statements into an array of tstl.Statements */
211-
private transformStatements(statements: ts.Statement[] | ReadonlyArray<ts.Statement>): tstl.Statement[] {
211+
private transformStatements(statements: readonly ts.Statement[]): tstl.Statement[] {
212212
const tstlStatements: tstl.Statement[] = [];
213213
(statements as ts.Statement[]).forEach(statement => {
214214
tstlStatements.push(...this.statementVisitResultToArray(this.transformStatement(statement)));

src/TSHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,15 +470,15 @@ export class TSHelper {
470470
return checker.getContextualType(expression) || checker.getTypeAtLocation(expression);
471471
}
472472

473-
public static getAllCallSignatures(type: ts.Type): ReadonlyArray<ts.Signature> {
473+
public static getAllCallSignatures(type: ts.Type): readonly ts.Signature[] {
474474
if (type.isUnion()) {
475475
return type.types.map(t => TSHelper.getAllCallSignatures(t)).reduce((a, b) => a.concat(b));
476476
}
477477
return type.getCallSignatures();
478478
}
479479

480480
public static getSignatureDeclarations(
481-
signatures: ReadonlyArray<ts.Signature>,
481+
signatures: readonly ts.Signature[],
482482
checker: ts.TypeChecker
483483
): ts.SignatureDeclaration[]
484484
{

src/lualib/ArrayFlatMap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function __TS__ArrayFlatMap<T, U>(
22
this: void,
33
array: T[],
4-
callback: (value: T, index: number, array: T[]) => U | ReadonlyArray<U>
4+
callback: (value: T, index: number, array: T[]) => U | readonly U[]
55
): U[] {
66
let result: U[] = [];
77
for (let i = 0; i < array.length; i++) {

src/tstl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ function performBuild(_args: string[]): void {
134134

135135
function performCompilation(
136136
rootNames: string[],
137-
projectReferences: ReadonlyArray<ts.ProjectReference> | undefined,
137+
projectReferences: readonly ts.ProjectReference[] | undefined,
138138
options: tstl.CompilerOptions,
139-
configFileParsingDiagnostics?: ReadonlyArray<ts.Diagnostic>
139+
configFileParsingDiagnostics?: readonly ts.Diagnostic[]
140140
): void {
141141
const program = ts.createProgram({
142142
rootNames,

test/unit/array.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test("Array access", () => {
1010

1111
test("Readonly Array access", () => {
1212
const result = util.transpileAndExecute(
13-
`const arr: ReadonlyArray<number> = [3,5,1];
13+
`const arr: readonly number[] = [3,5,1];
1414
return arr[1];`,
1515
);
1616
expect(result).toBe(5);

0 commit comments

Comments
 (0)