I attempted to create a patch for deno which upgrades it to TypeScript 2.9.1 but there is a change in 2.9.1 that is currently blocking that to do with an incorrect code assumption.
I get the following error whenever running any code:
TypeError: Cannot read property 'base64encode' of undefined
at Object.base64encode (../node_modules/typescript/lib/typescript.js:12079:18)
at Object.getSourceMappingURL (../node_modules/typescript/lib/typescript.js:73929:46)
at printSourceFileOrBundle (../node_modules/typescript/lib/typescript.js:74550:48)
at emitJsFileOrBundle (../node_modules/typescript/lib/typescript.js:74499:13)
at emitSourceFileOrBundle (../node_modules/typescript/lib/typescript.js:74456:13)
at forEachEmittedFile (../node_modules/typescript/lib/typescript.js:74365:30)
at Object.emitFiles (../node_modules/typescript/lib/typescript.js:74446:9)
at emitWorker (../node_modules/typescript/lib/typescript.js:78992:33)
at ../node_modules/typescript/lib/typescript.js:78952:66
at runWithCancellationToken (../node_modules/typescript/lib/typescript.js:79043:24)
I will open the issue and like raise a PR to TypeScript related to this code:
function base64encode(host, input) {
if (host.base64encode) {
return host.base64encode(input);
}
return convertToBase64(input);
}
As simple fix the following seems to work:
--- if (host.base64encode) {
+++ if (host && host.base64encode) {
Where host is actually possible undefined (it is the ts.sys
and ts.sys
is currently undefined, though it is expected to be defined when running under Node.js or the ChakraCore runtime, so I suspect in the long term deno would want to contribute a patch so that some host functionality is exposed in the ts.sys
object.
So main TypeScript issue is merged and closed, but it is only tagged to be released with TypeScript 3.0, which is in July. It would have to be advocated for to get it into the patch release of 2.9 though.
This can be closed in lieu of #417
Thanks
Most helpful comment
So main TypeScript issue is merged and closed, but it is only tagged to be released with TypeScript 3.0, which is in July. It would have to be advocated for to get it into the patch release of 2.9 though.