Description
TypeScript Version:
2.6.2
Search Terms:
truncate comments
Code
The following code when compiled with "declaration": true
:
/**
* @module botbuilder-choices
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const breakingChars = " \n\r~`!@#$%^&*()-+={}|[]\\:\";'<>?,./";
export interface Token {
start: number;
end: number;
text: string;
normalized: string;
}
export type TokenizerFunction = (text: string, locale?: string) => Token[];
Expected behavior:
Should generate a .d.ts
file that looks like this:
/**
* @module botbuilder-choices
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
export interface Token {
start: number;
end: number;
text: string;
normalized: string;
}
export declare type TokenizerFunction = (text: string, locale?: string) => Token[];
Actual behavior:
But instead it generates this with the comments stripped off:
export interface Token {
start: number;
end: number;
text: string;
normalized: string;
}
export declare type TokenizerFunction = (text: string, locale?: string) => Token[];
If I simply change the code to this then it works fine:
/**
* @module botbuilder-choices
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
export interface Token {
start: number;
end: number;
text: string;
normalized: string;
}
const breakingChars = " \n\r~`!@#$%^&*()-+={}|[]\\:\";'<>?,./";
export type TokenizerFunction = (text: string, locale?: string) => Token[];
The compiler will truncate the leading comments if the first construct in the file isn't exported. The same thing happens if you import
a type from a module but that type isn't referenced by something you export
.
The leading comments are needed by a TypeDoc plugin we're using and every time this happens what ever is in the file gets dropped from our documentation. I've been working around the issue by manually checking the generated .d.ts files for months and now other devs on our team are starting to accidentally break our docs.
I really need this fixed...