无法找到将ember-cli应用迁移到TypeScript

时间:2016-10-06 22:22:39

标签: ember.js typescript ember-cli

我想在我的ember项目中尝试ts(我之前在小应用程序上尝试)

所以我有

"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

我有下一个文件

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'.

我尝试将声明放入单独的文件中并将其添加到files部分,但得到相同的结果

P.S。我尝试使用tildeio/broccoli-typescript-compiler但它对我不起作用(或者我做错了) - 但如果你有一些指导(与ember-cli一起) - 如果你分享

1 个答案:

答案 0 :(得分:0)

现在你可以试试这个:

yarn add typescript -D
ember install ember-cli-typescript@latest

https://github.com/typed-ember/ember-cli-typescript#setup-and-configuration

手前安装打字稿会阻止此错误:

  

找不到模块'打字稿'