Comments (9)
Hi are there future plans to support a tsconfig file? I need to enable -resolveJsonModule in order to import JSON files.
from tslab.
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.
thanks
from tslab.
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.
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.
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.
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.
Bump
from tslab.
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)
- Cannot import packages from nodejs. HOT 2
- How to specify node version? HOT 1
- library issues
- Error [ERR_REQUIRE_ESM]: require() of ES Module not supported. HOT 2
- Using tslab as interactive documentation with turborepo #question
- Running notebooks from VSCode HOT 1
- General: future plans for tslab HOT 2
- are there any "magics" in this kernel?
- No BigInt support
- unexpected error: TypeError: Cannot read properties of undefined (reading 'locals') HOT 9
- Stop spreading such non-sense like JS is 40x faster than Python HOT 4
- Fails to install with Python 3.11
- unexpected error: Error: Unexpected pending rebuildTimer HOT 1
- Importing local files?
- Outputting tables?
- Is Jupyterlab 4 officially supported?
- jupyter is not installed in this Python. HOT 1
- README enhancement for tslab install and --python option HOT 1
- README enhancement : Clarify "terminal"
- README enhancement : "Usage" section only applies to Unix/Linux
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tslab.