私は最初のTypescript定義ファイルを作成しようとしています。対象コード(index.js)filename.jsです:Typescript「エクスポートされた外部パッケージ型がモジュールではありません」
module.exports = {
extension: extension,
basename: basename,
removeSuffix: removeSuffix,
removeSuffixWithDelimiter: removeSuffixWithDelimiter,
appendSuffix: appendSuffix,
appendSuffixWithDelimiter: appendSuffixWithDelimiter,
directoryName: directoryName
}
function extension(filename) {}
function basename(filename) {}
function removeSuffix(filename) {}
function removeSuffixWithDelimiter(delimiter, filename) {}
function appendSuffix(suffix, filename) {}
function appendSuffixWithDelimiter(suffix, delimiter, filename) {}
function directoryName(filename) {}
私がこれまで持っている定義(index.d.ts)ファイル:
declare module "filename.js" {
export function extension(filename: string): string;
export function basename(filename: string): string;
export function removeSuffix(filename: string): string;
export function removeSuffixWithDelimiter(delimiter: string|number, filename: string): string;
export function appendSuffix(suffix: string, filename: string): string;
export function appendSuffixWithDelimiter(suffix: string, delimiter: string|number, filename: string): string;
export function directoryName(filename: string): string;
}
これはよく私のに十分な(オートコンプリート作品を作品編集者)が、私はコンパイルエラーを取得:
index.ts(21,29): error TS2656: Exported external package typings file 'filename.js/index.d.ts' is not a module. Please contact the package author to update the package definition.
このエラーが(新しい)活字体に何を意味し、そしてもっと重要なのは、どのように私はそれをより正確にするために、私の定義を変更する必要がありますか?あなたが提供するデータのための
これを修正できましたか?私は同じ問題を抱えている。 – emzero
@emzeroいいえ私はこれまでにできなかった –
うまくいけば、それはTS 2.0で修正されることを望む – emzero