Skip to content

Commit

Permalink
Merge pull request #30734 from andrewbranch/bug/30664 (#30892)
Browse files Browse the repository at this point in the history
Fall back from `globalReadonlyArrayType` to `globalArrayType` when transpiling
  • Loading branch information
andrewbranch authored and RyanCavanaugh committed Apr 12, 2019
1 parent 7eb4739 commit 1871048
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30293,7 +30293,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);

Expand Down
8 changes: 8 additions & 0 deletions src/testRunner/unittests/services/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }
});
});
}

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

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

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

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

0 comments on commit 1871048

Please sign in to comment.