microsoft / microsoft/TypeScript
emit code miss return type in .d.ts ( 3.9.0-dev.20200408 )
Open
Nobody has claimed this yet.
Needs Investigation
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied TypeScript 3.9.0-dev.20200408 example with the provided tsconfig.json and compare its generated .d.ts with the Playground's expected output. Trace declaration emit for the inferred getLifecycle return type; done when the generated declaration retains the pack variant and matches the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100