Giter VIP home page Giter VIP logo

Comments (9)

jzhang1 avatar jzhang1 commented on May 31, 2024 6

Hi are there future plans to support a tsconfig file? I need to enable -resolveJsonModule in order to import JSON files.

from tslab.

yunabe avatar yunabe commented on May 31, 2024 1

Internal compiler flags of tslab are defined in https://github.com/yunabe/tslab/blob/master/src/converter.ts (Ctrl-F esModuleInterop).

At this moment, it's not possible to control the internal compiler flags in tslab. As a short-term solution, I enabled experimentalDecorators in tslab (4ba7e17) and released the new version (v1.0.9).

from tslab.

phreed avatar phreed commented on May 31, 2024

thanks

from tslab.

misja avatar misja commented on May 31, 2024

I'm having an issue which may be related, i.e. a configuration option. I am unable to use console, as it will produce the following error:

Cannot find name 'console'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.

Looking at how the config is set up I see an isBrowser flag which adds dom (which is required to be able to use console). Apparently this is not being set, any pointers to track down why this is happening would be apprectated!

from tslab.

yunabe avatar yunabe commented on May 31, 2024

I am unable to use console, as it will produce the following error:

It's weird. Although we don't set dom to lib, tslab still should be able to find the definition of console from @types/node. Can you use other Node.js libraries like process.version? If you can not, tslab failed to load @types/node in your environment for some reason.

from tslab.

misja avatar misja commented on May 31, 2024

That will probably be it, same message when calling process.version. @types/nodes are on my system though (via debian packages node-typescript and node-typescript-types with nodejs v12.16.2). I won't be investigating further since I noticed jslab is actually doing typechecking and more which isn't what I expected (was looking to use as educational JS tool). E.g. was expecting this to just work:

var a = "world";
a = 42;

Apart from this, I really like the work you have done with this kernel implementation, will surely revisit some other time!

from tslab.

heavenkiller2018 avatar heavenkiller2018 commented on May 31, 2024

I have the same problem, and after run yarn add @types/node, the error was disappered.
But there are another errors, i have no idea how to fix it.

when I run the https://github.com/yunabe/tslab-examples/blob/master/notebooks/getting_started.ipynb file locally, the following error occurs:

    // This is 40x slower if you use Python.
    const n = 40;
    const start = Date.now()
    console.log(`naiveFib(${n}) = ${naiveFib(n)} (took ${Date.now() - start}ms)`)
4:19 - Cannot find name 'Date'.
5:58 - Cannot find name 'Date'.

my tsconfig.json is the same as the example:

{
  "compilerOptions": {
    "outDir": "lib",
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "ES2017",
    "lib": ["es2017"],
    "newLine": "LF",
    "rootDir": "src",
    "skipLibCheck": true,
    "declaration": true,
    "noImplicitAny": true
  },
  "include": ["src/**/*"]
}

and then I test Set and other parsts of the example file, the same as Date:

let a=new Set()
1:11 - Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.

let sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
const start = Date.now();
// Top-level await.
await sleep(500);
`Slept ${Date.now() - start}[ms]`


1:33 - Cannot find name 'Promise'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
2:15 - Cannot find name 'Date'.
5:10 - Cannot find name 'Date'.


{
    // class
    class MyObj {
        abc: number;
        xyz: string;
        constructor(abc: number, xyz: string) {
            this.abc = abc;
            this.xyz = xyz;
        }
    }
    // const and let
    const obj = new MyObj(123, 'hello');
    // Destructuring
    let {abc, xyz: klm} =  obj;
    // Enhanced Object Literals
    console.log({abc, klm});
    
    // Spread
    let [x, y, z] = [1, 2, 3];
    console.log({x, y, z})
    
    // Generator and for-of
    let array: number[] = [];
    for (let e of (function*(n: number) {
        for (let i = 0; i < n; i += 2) {
            yield i;
        }
    })(10)) {
        array.push(e * e);
    }
    console.log('array =', array);
}
19:9 - Type '[number, number, number]' must have a '[Symbol.iterator]()' method that returns an iterator.
24:19 - Type '{}' must have a '[Symbol.iterator]()' method that returns an iterator.
29:15 - Property 'push' does not exist on type '{}'.

what's wrong about my config?

from tslab.

RA80533 avatar RA80533 commented on May 31, 2024

Bump

from tslab.

MrYutz avatar MrYutz commented on May 31, 2024

I am having a similar issue. I am trying to use the new VSCode native integration.

fetch()
1:1 - Cannot find name 'fetch'.

However, Date() works.

from tslab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.