-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Import default issue (Cannot read properties of undefined) #31
Comments
Hey @ak99372, I tried to reproduce locally but it seems to be working fine for me with a regular setup (node 18, typescript latest). Here is what I did: # init a brand new typescript project
mkdir ts-hyperactiv
cd ts-hyperactiv
# install the deps
npm i -D typescript
npm i hyperactiv
# init typescript
./node_modules/.bin/tsc --init
# create an index file
mkdir src
echo "import hyperactiv from 'hyperactiv'
const obj = hyperactiv.observe({
a: 0,
b: 0,
c: 0
})
hyperactiv.computed(() => {
obj.c = obj.a + obj.b
})
obj.a = 1
console.log(obj.c)" > src/index.ts
# transpile to js
./node_modules/.bin/tsc
# run
node src/index.js
# output: 1 |
Thanks for looking into this @elbywan. I tried few different things myself, I have a monorepo with a lot of local commonjs packages. The issue points back to the tsconfig setup I use when transpiling .ts with tsc. Adding |
Hi @ak99372 and @elbywan. Below you will find the updated package.json that fixes that. I may send a PR for this, if @elbywan doesn’t get to it first. Thank you @elbywan. I'm using
|
Can someone shed some light on default import (using Typescript). This is the code using default import (matching the types from index.d.ts)
but then during run time default is undefined
if I do instead
import * as hyperactiv from "hyperactiv";
then compiler complains abouthyperactiv.observe
but it works at runtime.(my tsconfig: "module": "CommonJS")
The text was updated successfully, but these errors were encountered: