正直言って、実際に何が起こっているのかはほとんど分かりません。私はhereと表示されているものに基づいて宣言ファイルを作成しようとしています。ES6形式のExport-from Typescriptモジュール定義(module.d.ts)
私は(これは就業規則に名前を変更し、編集した)これらのファイルを持っている:
project_one
some_interface.ts
import SomeOtherInterface from "some_other_file";
interface ThisInterface
{
aMethodRequiring(aThing: SomeOtherInterface): void;
}
export default ThisInterface;
index.d.ts
export { default as ThisInterface } from "some_interface";
tsconfig.json
{
"compilerOptions": {
"baseUrl": "src",
"noImplicitAny": true,
"target": "es2015"
},
"exclude": [
"src/**/*.type.ts"
],
"include": [
"src/**/*.ts"
]
}
project_two
some_class.ts
/// <reference types="project_one" />
/*^This seems to be fine^*/
import SomethingInThisProject from "a_file_in_this_project";
import { ThisInterface } from "project_one"; // <=== This is the line that fails.
class ThatClass
{
private instanceOfThisInterface : ThisInterface;
constructor(saidInstance: ThisInterface)
{
this.instanceOfThisInterface = saidInstance;
}
// The useful stuff
}
export default ThatClass;
tsconfig.json
{
"compilerOptions": {
"baseUrl": "src",
"noImplicitAny": true,
"target": "es2015"
},
"exclude": [
"src/**/*.type.ts"
],
"include": [
"src/**/*.ts"
]
}
package.json
{
"name": "project_two",
"version": "0.1.0",
"description": "A Second Project",
"main": "index.js",
"repository": "https://github.com/project/two",
"author": "Cyle Ven Dawson",
"license": "MIT",
"devDependencies": {
...
},
"dependencies": {
...
"project_one": "^0.5.0"
}
}
活字体がうまくproject_one宣言ファイルを検索します。しかし、それはimport
ということで私に怒鳴ります。[ts] cannot find module 'project_one'.
私は宣言ファイルから何かをインポートしようとするよりも、このコードでもっと間違っていると思いますが、今のところ私はimport
行を動作させようとしています。
私は何を誤解しましたか?
package.jsonを表示できますか? 'project_one'は' project_two'の依存関係として正しく登録されていますか? –
@ E_net4 package.jsonの内容が追加されました。 'project_one'は、示されているように依存関係として設定されます。 – dawsonc623