-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
π Search Terms
".d.ts","jsdoc"
β Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
β Suggestion
When generating .d.ts, if the referenced type is not exported, take one of the following actions:
- Compile error, indicating that necessary types have not been exported
- Automatically generate non exported types into .d.ts
- Maintain the existing implementation and only add jsdoc comments(prefered)
Here is a simple example
- I wrote a simple library 1
// myLib/index.d.ts
type FilterString<T> = {
[K in keyof T as T[K] extends string ? never : K]: T[K];
}
export function define<T>(p: T): FilterString<T>;
- Reference library 1 in library 2
import { define } from 'myLib'
export const test = define({
/** jsdoc 1 */
a: 5,
/** jsdoc 2 */
b: '',
})
- Compile library 2 to generate .d.ts
// without jsdoc: type FilterString without export
export declare const test: {
a: number; // Don't let jsdoc be lost (prefered)
};
// with jsdoc: type FilterString with export
// Alternatively, generate the FilterString type into .d.ts as well
export declare const test: import("myLib").FilterString<{
/** jsdoc 1 */
a: number;
/** jsdoc 2 */
b: string;
}>;
π Motivating Example
When writing libraries, maintain consistent JSDoc annotations between the development and release environments
π» Use Cases
- When writing libraries, maintain consistent JSDoc annotations between the development and release environments
- I only discovered that JSDoc was missing when it was released
- Manually find the type that has not been exported and add it to the export
Metadata
Metadata
Assignees
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript