ほとんどのプロジェクトのベースとなる npm パッケージを作成しようとしていますが、次の点でいくつかの問題があります。
ベースのindex.d.ts
npm パッケージは次のようになります。
export * from './src/core';
declare module '*.html' {
const template: string;
export default template;
}
一番上の行はうまく機能し、コア フォルダー内のモジュールにアクセスできますが、2 番目の部分は機能しません。
しかし、自分のプロジェクトに同じコードを配置するとcustom.d.ts
、html ファイルのインポートがうまく機能します。
(いくつかの部分が削除されて package.json
います)は次のようになります。
{
"version": "0.0.0",
"license": "ISC",
"main": "dist/main.bundle.js",
"module": "./index.js",
"types": "./index.d.ts",
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3"
}
}
フォルダ構造:
app/
├── node_modules/
| └── base/
│ ├── src/
│ | └── core/
│ | └── ....
│ └── index.d.ts
├── src/
│ └── ...
└── custom.d.ts