2016-09-26 6 views
0

私はタイスクリプトを学んでいます。 node_modules/.bin/tscを実行tsconfig.jsonのどのオプションがエラーを引き起こしていますか?

interface FooOptions { 
    x: string; 
    y: string; 
} 

function getFoo(opt: FooOptions) { 
    return opt.x + opt.y; 
} 

export {getFoo, FooOptions}; 

は、次のエラー得られます

$ node_modules/.bin/tsc 
t.ts(6,22): error TS4078: Parameter 'opt' of exported function has or is using private name 'FooOptions'. 

をしかし、成功しnode_modules/.bin/tsc t.ts実行されます。 the documentによると

:エラーの原因となっている私のtsconfig.jsonでオプション

By invoking tsc with no input files, in which case the compiler searches for the tsconfig.json file starting in the current directory and continuing up the parent directory chain.

?そして、エラーはどういう意味ですか?

{ 
    "compilerOptions": { 
    "target": "es5", 
    "outDir": "dist", 
    "module": "commonjs", 
    "declaration": true, 
    "noImplicitAny": true, 
    "removeComments": true, 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "inlineSources": true 
    }, 
    "exclude": [ 
    "node_modules", 
    "dist" 
    ] 
} 

答えて

0

はあなたにもインタフェースをエクスポートする必要があります動作します

export interface FooOptions { 
    x: string; 
    y: string; 
} 
+0

を! 'export interface FooOptions'と' export {getFoo、FooOptions};の違いは何ですか? ''なぜnode_modules/.bin/tsc t.ts'がうまく動作しますか? – zjk

+0

'tsc'を実行したときになぜこのエラーが表示されないのか分かりません。問題を再現しようとしたときにエラーがスローされました –

関連する問題