Ich lerne Typoskript.Welche Option in meinem tsconfig.json verursacht einen Fehler?
interface FooOptions {
x: string;
y: string;
}
function getFoo(opt: FooOptions) {
return opt.x + opt.y;
}
export {getFoo, FooOptions};
node_modules/.bin/tsc
Laufen gibt den folgenden Fehler:
$ node_modules/.bin/tsc
t.ts(6,22): error TS4078: Parameter 'opt' of exported function has or is using private name 'FooOptions'.
Aber node_modules/.bin/tsc t.ts
erfolgreich ausgeführt wird.
Nach the document:
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.
, welche Option in meinem tsconfig.json den Fehler verursacht? Und was bedeutet der Fehler?
{
"compilerOptions": {
"target": "es5",
"outDir": "dist",
"module": "commonjs",
"declaration": true,
"noImplicitAny": true,
"removeComments": true,
"moduleResolution": "node",
"sourceMap": true,
"inlineSources": true
},
"exclude": [
"node_modules",
"dist"
]
}
, das funktioniert! Ich frage mich, was ist der Unterschied zwischen 'export interface FooOptions 'und' export {getFoo, FooOptions}; 'Und warum funktioniert' node_modules/.bin/tsc t.ts' erfolgreich? – zjk
Ich bin nicht sicher, warum Sie diesen Fehler nicht erhalten, wenn Sie 'TSC' ausführen. Als ich versuchte, das Problem zu reproduzieren, wurde der Fehler ausgelöst –