ignite
ignite copied to clipboard
import model on root-store file from models/index.ts is causing error
What's going on?
When i try to import a model in the root-store file from models/index.ts its throw the following error:
Error: [mobx-state-tree] expected mobx-state-tree type as argument 1, got undefined instead
Steps to reproduce
- generate new model:
ignite generate model testing
- import model in root-store:
import { TestingModel } from "../"
if i importing using the following syntax it works: import { TestingModel } from "../testing/testing";
npx ignite-cli doctor
results:
System
platform win32
arch x64
cpu 12 cores Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
directory myApp D:\Projects\myApp
JavaScript (and globally-installed packages)
node 16.11.0 C:\Program Files\nodejs\node.EXE
npm 8.0.0 C:\Program Files\nodejs\npm.CMD
@nestjs/cli 8.1.4
nest-cli 0.0.5
npm 8.0.0
yarn 1.22.15 C:\Program Files (x86)\Yarn\bin\yarn.CMD
depcheck 1.4.2
expo-cli 4.12.11
ignite-cli 7.5.0
pm2 5.1.2
Ignite ignite-cli 7.5.0 C:\Users\lomba\AppData\Local\Yarn\bin\ignite.CMD ignite src build C:\Users\lomba\AppData\Local\Yarn\Data\global\node_modules\ignite-cli\build
Android java 1.8.0_281 C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.EXE android home - C:\Users\lomba\AppData\Local\Android\Sdk
Im not sure what's going on without more details on the structure of your project. This looks like more a problem of ts and import logic than ignite though
I am using the default ignite project structure.......Maybe is something related with the tsconfig file.....
@ericklombardo can you please paste your npx ignite-cli doctor
and your tsconfig.json
in the project directory? That would be very helpful in providing us more information to better troubleshoot this issue.
I'm on Ignite v7.13.1 and just the same command and didn't have an issue (no changes were done to my tsconfig
file since "igniting" the project).
My thought is this is using an older version of Ignite that was then on an older version of TS which would require you to do one of the following:
-
import { TestingModel } from "../index"
to import fromapp/models/index.ts
file -
import { TestingModel } from "../testing/testing"
to import from the generatedapp/models/testing/testing.ts
file
Hi, ignite-cli give me errors
this is my tsconfig.json
{ "compilerOptions": { "allowJs": false, "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "jsx": "react-native", "module": "es2015", "moduleResolution": "node", "noImplicitAny": false, "noImplicitReturns": true, "noImplicitThis": true, "noUnusedLocals": true, "sourceMap": true, "target": "esnext", "lib": [ "esnext", "dom" ], "skipLibCheck": true, "resolveJsonModule": true, "baseUrl": "." }, "exclude": [ "node_modules" ], "include": [ "index.js", "app", "test", "storybook", "scripts" ], "extends": "expo/tsconfig.base" }
@ericklombardo Thanks for that information. A couple follow up questions:
- Your initial message pointed out you were using Ignite v7.5.0 from what I assume is a global package you installed (probably
yarn global add ignite-cli
. Can you confirm you've since deleted it and are usingnpx ignite-cli *
? That error seems to be from our older versions that we've solved since. - Did my answer in regards to your import make sense? Does it solve your issue?
Hi, i just update to the latest version for ignite-cli, but i am still having the issue:

There has been a lot of changes since this issue last had activity. We have release a new major version of Ignite, codenamed Maverick. This is going to be closed for now, but please re-open if this still needs attention.