Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building ”modern” tsc #173

Open
helander opened this issue Mar 27, 2023 · 3 comments
Open

Building ”modern” tsc #173

helander opened this issue Mar 27, 2023 · 3 comments

Comments

@helander
Copy link

Have anyone compiled a ”modern” version of tsc (typescript compiler) with qjsc? The patch file available in the tar mentioned in the documentation does not ”work” with the ”current” typescript package.

@zeromake
Copy link

zeromake commented Apr 4, 2023

tsc

tsc-5.0.3.patch

On macosx

> curl -OL https://bellard.org/quickjs/quickjs-2021-03-27.tar.xz
> tar xf quickjs-2021-03-27.tar.xz && cd quickjs-2021-03-27
> make
> cd ..
> curl -OL https://globalcdn.nuget.org/packages/microsoft.typescript.msbuild.5.0.3.nupkg
> unzip microsoft.typescript.msbuild.5.0.3.nupkg -d tsc
> cd tsc/tools/tsc
> curl -OL https://github.com/bellard/quickjs/files/11146444/tsc-5.0.3.patch
> patch -p0 < tsc-5.0.3.patch && cd -
> ./quickjs-2021-03-27/qjsc -o tsc/tools/tsc/tsc tsc/tools/tsc/tsc.js
> echo 'console.log("hello");' > 1.ts
> ./tsc/tools/tsc/tsc 1.ts
> cat 1.js
console.log("hello");

@helander
Copy link
Author

Thank you 😃

@yne
Copy link

yne commented Jul 15, 2024

We could also add to the returned getQuickJSSystem object the following methods:

    return {
      //...
      getWidthOfTerminal() {
        const [width, _height] = os.ttyGetWinSize(1);
        return width;
      },
      writeOutputIsTTY() {
        return os.isatty(1);
      },
      // readFile: function (path, _encoding) { ...
    }

to get the same output color/layout as node

Also, readFile and writeFile shall not fail silently in order for tsc to create intermediate folder when outputing file

      readFile: function (path, _encoding) {
        const f = std.open(path, "r");
        if (!f)return void 0;
        const ret = f.readAsString();
        f.close();
        return ret;
      },
      writeFile: function (path, data, writeByteOrderMark) {
        const f = std.open(path, "w+");
        if (!f)
          throw new Error(`Unable to write ${path}`);
        f.puts(data);
        f.close();
      },

I'll try to upstream the patch so (at least) the qjs --std tsc.js ... could work out of the box

@zeromake is the removal of "use strict"; to be in sloppy mode necessary ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants