ignite icon indicating copy to clipboard operation
ignite copied to clipboard

import model on root-store file from models/index.ts is causing error

Open ericklombardo opened this issue 3 years ago • 6 comments

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

  1. generate new model: ignite generate model testing
  2. 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

ericklombardo avatar Nov 06 '21 14:11 ericklombardo

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

1mike12 avatar Nov 21 '21 16:11 1mike12

I am using the default ignite project structure.......Maybe is something related with the tsconfig file.....

ericklombardo avatar Nov 21 '21 17:11 ericklombardo

@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 from app/models/index.ts file
  • import { TestingModel } from "../testing/testing" to import from the generated app/models/testing/testing.ts file

mazenchami avatar Jun 27 '22 15:06 mazenchami

Hi, ignite-cli give me errors image 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 avatar Jun 27 '22 21:06 ericklombardo

@ericklombardo Thanks for that information. A couple follow up questions:

  1. 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 using npx ignite-cli *? That error seems to be from our older versions that we've solved since.
  2. Did my answer in regards to your import make sense? Does it solve your issue?

mazenchami avatar Jun 28 '22 16:06 mazenchami

Hi, i just update to the latest version for ignite-cli, but i am still having the issue:

issue ignite

ericklombardo avatar Jun 29 '22 20:06 ericklombardo

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.

joshuayoes avatar Oct 04 '22 17:10 joshuayoes