grant / ts2gas

A function that transpiles TypeScript to Google Apps Script.
http://npmjs.com/ts2gas
MIT License
88 stars 11 forks source link

Small changes with no functional impact #38

Closed PopGoesTheWza closed 5 years ago

PopGoesTheWza commented 5 years ago

Build and test passed.

PopGoesTheWza commented 5 years ago

Typescript 3.4 features tests cnow complete with version 3.4.4:

# testTypeScript_34x_improvedReadonly
v--TS--v
// Improved support for read-only arrays and tuples
function f1(mt: [number, number], rt: readonly [number, number]) {
  mt[0] = 1;  // Ok
  // rt[0] = 1;  // Error, read-only element
}

// next function declaration crashes with Typescript version < 3.4.4
function f2(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) {
  //   ma = ra;  // Error
  ma = mt;  // Ok
  //   ma = rt;  // Error
  ra = ma;  // Ok
  ra = mt;  // Ok
  ra = rt;  // Ok
  //   mt = ma;  // Error
  //   mt = ra;  // Error
  //   mt = rt;  // Error
  //   rt = ma;  // Error
  //   rt = ra;  // Error
  rt = mt;  // Ok
}

type ReadWrite<T> = { -readonly [P in keyof T] : T[P] };

type T0 = Readonly<string[]>;  // readonly string[]
type T1 = Readonly<[number, number]>;  // readonly [number, number]
type T2 = Partial<Readonly<string[]>>;  // readonly (string | undefined)[]
type T3 = Readonly<Partial<string[]>>;  // readonly (string | undefined)[]
type T4 = ReadWrite<Required<T3>>;  // string[]
–––
// Compiled using ts2gas 1.6.2 (TypeScript 3.4.4)
var exports = exports || {};
var module = module || { exports: exports };
// Improved support for read-only arrays and tuples
function f1(mt, rt) {
    mt[0] = 1; // Ok
    // rt[0] = 1;  // Error, read-only element
}
// next function declaration crashes with Typescript version < 3.4.4
function f2(ma, ra, mt, rt) {
    //   ma = ra;  // Error
    ma = mt; // Ok
    //   ma = rt;  // Error
    ra = ma; // Ok
    ra = mt; // Ok
    ra = rt; // Ok
    //   mt = ma;  // Error
    //   mt = ra;  // Error
    //   mt = rt;  // Error
    //   rt = ma;  // Error
    //   rt = ra;  // Error
    rt = mt; // Ok
}
^--GS--^
grant commented 5 years ago

Need the Travis to pass.

PopGoesTheWza commented 5 years ago

Need the Travis to pass.

I am unfamiliar with Travis. Do you have any idea why it keeps using ts 3.4.3?

PopGoesTheWza commented 5 years ago

@grant I found out why this PR was stuck in Travis. typescript version was incorrect.

grant commented 5 years ago

Looks good, thanks.