deno and TypeScript 2.9.1

Created on 3 Jun 2018  路  3Comments  路  Source: denoland/deno

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.

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.

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ry picture ry  路  3Comments

amiteshore picture amiteshore  路  3Comments

ry picture ry  路  3Comments

ry picture ry  路  3Comments

metakeule picture metakeule  路  3Comments