Fall back from globalReadonlyArrayType to globalArrayType when transpiling

This commit is contained in:
Andrew Branch
2019-04-03 11:27:53 -07:00
parent 5869662c3f
commit 9475bf7d9e
2 changed files with 9 additions and 1 deletions
+1 -1
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);
@@ -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 } }
});
});
}