在将ember-cli应用程序迁移到TypeScript时找不到模块 [英] Can't find module on migrating ember-cli app to TypeScript
问题描述
我想在我的ember项目中尝试ts(我以前在小型应用程序上尝试过)
I want to try ts inside my ember project ( I try it before on small applications )
所以我有
"ember-cli-typify": "^0.3.1",
"typescript": "^2.0.3"
"typings": "^1.4.0"
"ember-cli": "2.4.3"
在我的 tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"allowJs": true,
"moduleResolution": "node",
"noEmitOnError": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"ember": ["node_modules/at-types-ember"],
"npm:*": ["local-types/*"],
"*": ["local-types/*"]
}
},
"include": [
"app/**/*"
],
"files": [
"typings/index.d.ts"
]
}
我尝试移动 app / app.js
放入 app / app.ts
我接下来有一个内部文件
inside file I have next
import Ember from 'ember'; // this was solved via typings dt~ember
import Resolver from './resolver.js'; // here I just add `.js` but I'm interested how to avoid it
import loadInitializers from 'ember-load-initializers'; // here I have first error
import config from './config/environment';
内部 typings / index.d.ts
我添加一行
declare module 'ember-load-initializers' { var out: any; export = out; }
但我还是
.../tree_stabilizer-output_path-UJl8FIXV.tmp/apollo/app.ts (6, 30): Cannot find module 'ember-load-initializers'.
我尝试将声明放入单独的文件并将其添加到个文件
部分,但结果相同
I try put declaration into separate file and add it into files
section, but got the same result
PS我尝试使用 tildeio / broccoli-typescript-compiler
,但是它对我不起作用(或者我做错了)-但是如果您对此有一些说明(在加上ember-cli)-如果您共享
P.S. I try to use tildeio/broccoli-typescript-compiler
but It doesn't work for me ( or I do something wrong ) - but if you have some instruction for it ( in couple with ember-cli ) -- it will be great if you share
推荐答案
现在很好,您可以尝试以下方法:
Now you can try this:
yarn add typescript -D
ember install ember-cli-typescript@latest
https://github.com/typed-ember/ember-cli-typescript#setup-and-configuration
事先安装打字稿将防止此错误:
installing typescript before hand will prevent this error:
找不到模块'打字稿'
Cannot find module 'typescript'
这篇关于在将ember-cli应用程序迁移到TypeScript时找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!