Repository navigation
TypeError: Cannot read property 'instantiations' of undefined when use as const #30664
Description
Activity
j-oliveras commented
on Mar 30, 2019 ContributorMore actionsAnders Hejlsberg (@ahejlsberg) I investigated this: inside
createArrayTypefunction on checker.ts, the variableglobalReadonlyArrayTypeis undefined as if its initialization cannot find theReadonlyArraydeclaration.I cannot link to the lines because the file is too big for GitHub.
initialization cannot find the ReadonlyArray declaration.
That's kind of expected since there is no
lib.xxx.d.tsused bytranspileModule. DefiningReadonlyArray<T>in the transpiled file should work around the crash.This probably needs an additional condition to check if the global type is actually available. Though I don't know what a reasonable fallback would be.
Note that this might happen forglobalArrayTypeand friends.I have this issue when using parcel to compile typescript files that use
as constsyntax.patrickmichalina commented
on Apr 3, 2019 More actionsSeeing the same failure when applying
readonlyto tuples likereadonly [any, any]I experience the same issue with typescript 3.4.1 while running
ts.transpileModuleon the sample code for Improved support for read-only arrays and tuplesError test code can be reduced to this:
function f2(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) { }
Reacted by Andrew Branch and codelovesmeWould you please release the fix as 3.4.x?
Reacted by PopGoesTheWza, Pavel Lozinsky and Veniamin KrolRyanCavanaugh commented
on Apr 12, 2019 MemberMore actionsAndrew Branch (@andrewbranch) please port the fix PR to the release-3.4 branch. Thanks!
andrewbranch commented
on Apr 12, 2019 MemberMore actionsDone: #30892
Reacted by Dmitry and RoyHappened on
(x: readonly T[])andrewbranch commented
on May 17, 2019 MemberMore actionsRe-closing as this has been released
- locked as resolved and limited conversation to collaborators
on Oct 21, 2025
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
Expected behavior:
Actual behavior:
Playground Link:
Related Issues: