Merge pull request #30734 from andrewbranch/bug/30664

Fall back from `globalReadonlyArrayType` to `globalArrayType` when transpiling
This commit is contained in:
Andrew Branch
2019-04-04 11:57:08 -07:00
committed by GitHub
6 changed files with 17 additions and 1 deletions

View File

@@ -30307,7 +30307,7 @@ namespace ts {
autoArrayType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
}
globalReadonlyArrayType = <GenericType>getGlobalTypeOrUndefined("ReadonlyArray" as __String, /*arity*/ 1);
globalReadonlyArrayType = <GenericType>getGlobalTypeOrUndefined("ReadonlyArray" as __String, /*arity*/ 1) || globalArrayType;
anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
globalThisType = <GenericType>getGlobalTypeOrUndefined("ThisType" as __String, /*arity*/ 1);

View File

@@ -445,5 +445,13 @@ var x = 0;`, {
}
}
});
transpilesCorrectly("Supports readonly keyword for arrays", "let x: readonly string[];", {
options: { compilerOptions: { module: ModuleKind.CommonJS } }
});
transpilesCorrectly("Supports 'as const' arrays", `([] as const).forEach(k => console.log(k));`, {
options: { compilerOptions: { module: ModuleKind.CommonJS } }
});
});
}

View File

@@ -0,0 +1,2 @@
[].forEach(function (k) { return console.log(k); });
//# sourceMappingURL=file.js.map

View File

@@ -0,0 +1,2 @@
[].forEach(function (k) { return console.log(k); });
//# sourceMappingURL=file.js.map

View File

@@ -0,0 +1,2 @@
var x;
//# sourceMappingURL=file.js.map

View File

@@ -0,0 +1,2 @@
var x;
//# sourceMappingURL=file.js.map