microsoft / microsoft/TypeScript
emit code miss return type in .d.ts ( 3.9.0-dev.20200408 )
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
TypeScript Version: Version 3.9.0-dev.20200408
Search Terms:
Code
export declare const lifecycleMap: {
install: {
readonly name: "install";
readonly before: readonly ["preinstall"];
readonly after: readonly ["postinstall", "prepublish", "prepare", "preshrinkwrap", "shrinkwrap", "postshrinkwrap"];
};
pack: {
readonly name: "pack";
readonly ignoreSelf: true;
readonly before: readonly ["prepublish", "prepare", "prepack"];
readonly after: readonly ["postpack"];
};
publish: {
readonly name: "publish";
readonly before: readonly ["prepublish", "prepare", "prepublishOnly", "prepack", "postpack"];
readonly after: readonly ["postpublish"];
};
};
export interface ILifecycleEntry
{
readonly name: string;
readonly ignoreSelf?: boolean;
readonly before: readonly string[];
readonly after: readonly string[];
}
export type ILifecycleMapKeys = keyof typeof lifecycleMap;
export type ILifecycleMap<K extends string = string> = typeof lifecycleMap & Record<K, ILifecycleEntry>;
export function getLifecycleCore<K extends ILifecycleMapKeys>(scriptName: string | K)
{
if (isKnownLifecycleKey(scriptName))
{
return lifecycleMap[scriptName]
}
return (lifecycleMap as ILifecycleMap)[scriptName]
}
export function getLifecycle<K extends string | ILifecycleMapKeys>(scriptName: K)
{
return getLifecycleCore(scriptName) ?? {
name: scriptName,
before: [
`pre${scriptName}`
],
after: [
`post${scriptName}`
],
}
}
export function isKnownLifecycleKey<K extends ILifecycleMapKeys>(scriptName: string | K): scriptName is ILifecycleMapKeys
{
return scriptName in lifecycleMap
}
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es2019",
"jsx": "preserve",
"moduleResolution": "node",
"allowJs": false,
"allowUmdGlobalAccess": false,
"sourceMap": true,
"inlineSourceMap": false,
"inlineSources": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"strict": false,
"strictBindCallApply": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"noImplicitThis": true,
"preserveConstEnums": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"noErrorTruncation": true,
"locale": "zh-TW",
"removeComments": false,
"traceResolution": false,
"newLine": "lf",
"esModuleInterop": true
},
Expected behavior:
export declare function getLifecycle<K extends string | ILifecycleMapKeys>(scriptName: K): {
readonly name: "install";
readonly before: readonly ["preinstall"];
readonly after: readonly ["postinstall", "prepublish", "prepare", "preshrinkwrap", "shrinkwrap", "postshrinkwrap"];
} | {
readonly name: "pack";
readonly ignoreSelf: true;
readonly before: readonly ["prepublish", "prepare", "prepack"];
readonly after: readonly ["postpack"];
} | {
readonly name: "publish";
readonly before: readonly ["prepublish", "prepare", "prepublishOnly", "prepack", "postpack"];
readonly after: readonly ["postpublish"];
} | ILifecycleEntry;
Actual behavior:
export declare function getLifecycle<K extends string | ILifecycleMapKeys>(scriptName: K): {
readonly name: "install";
readonly before: readonly ["preinstall"];
readonly after: readonly ["postinstall", "prepublish", "prepare", "preshrinkwrap", "shrinkwrap", "postshrinkwrap"];
} | {
readonly name: "publish";
readonly before: readonly ["prepublish", "prepare", "prepublishOnly", "prepack", "postpack"];
readonly after: readonly ["postpublish"];
} | ILifecycleEntry;
export declare function getLifecycle<K extends string | ILifecycleMapKeys>(scriptName: K): {
readonly name: "install";
readonly before: readonly ["preinstall"];
readonly after: readonly ["postinstall", "prepublish", "prepare", "preshrinkwrap", "shrinkwrap", "postshrinkwrap"];
} | {
- readonly name: "pack";
- readonly ignoreSelf: true;
- readonly before: readonly ["prepublish", "prepare", "prepack"];
- readonly after: readonly ["postpack"];
- } | {
readonly name: "publish";
readonly before: readonly ["prepublish", "prepare", "prepublishOnly", "prepack", "postpack"];
readonly after: readonly ["postpublish"];
} | ILifecycleEntry;
Playground Link:
Related Issues:
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Führen Sie das bereitgestellte Beispiel für TypeScript 3.9.0-dev.20200408 mit der bereitgestellten tsconfig.json aus und vergleichen Sie die generierte .d.ts mit der erwarteten Ausgabe des Playgrounds. Verfolgen Sie den Deklarations-Emit für den inferierten Rückgabetyp von getLifecycle; abgeschlossen, wenn die generierte Deklaration die pack-Variante beibehält und dem erwarteten Verhalten entspricht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 48/100