未验证 提交 435f287a 编写于 作者: A Alex Dima

Remove support for `@monacodtsreplace` since TS has gotten a lot better at emitting dts

上级 0eaaf654
...@@ -149,26 +149,6 @@ function getMassagedTopLevelDeclarationText(ts, sourceFile, declaration, importN ...@@ -149,26 +149,6 @@ function getMassagedTopLevelDeclarationText(ts, sourceFile, declaration, importN
} }
}); });
} }
else if (declaration.kind === ts.SyntaxKind.VariableStatement) {
const jsDoc = result.substr(0, declaration.getLeadingTriviaWidth(sourceFile));
if (jsDoc.indexOf('@monacodtsreplace') >= 0) {
const jsDocLines = jsDoc.split(/\r\n|\r|\n/);
let directives = [];
for (const jsDocLine of jsDocLines) {
const m = jsDocLine.match(/^\s*\* \/([^/]+)\/([^/]+)\/$/);
if (m) {
directives.push([new RegExp(m[1], 'g'), m[2]]);
}
}
// remove the jsdoc
result = result.substr(jsDoc.length);
if (directives.length > 0) {
// apply replace directives
const replacer = createReplacerFromDirectives(directives);
result = replacer(result);
}
}
}
result = result.replace(/export default /g, 'export '); result = result.replace(/export default /g, 'export ');
result = result.replace(/export declare /g, 'export '); result = result.replace(/export declare /g, 'export ');
result = result.replace(/declare /g, ''); result = result.replace(/declare /g, '');
......
...@@ -178,25 +178,6 @@ function getMassagedTopLevelDeclarationText(ts: typeof import('typescript'), sou ...@@ -178,25 +178,6 @@ function getMassagedTopLevelDeclarationText(ts: typeof import('typescript'), sou
// life.. // life..
} }
}); });
} else if (declaration.kind === ts.SyntaxKind.VariableStatement) {
const jsDoc = result.substr(0, declaration.getLeadingTriviaWidth(sourceFile));
if (jsDoc.indexOf('@monacodtsreplace') >= 0) {
const jsDocLines = jsDoc.split(/\r\n|\r|\n/);
let directives: [RegExp, string][] = [];
for (const jsDocLine of jsDocLines) {
const m = jsDocLine.match(/^\s*\* \/([^/]+)\/([^/]+)\/$/);
if (m) {
directives.push([new RegExp(m[1], 'g'), m[2]]);
}
}
// remove the jsdoc
result = result.substr(jsDoc.length);
if (directives.length > 0) {
// apply replace directives
const replacer = createReplacerFromDirectives(directives);
result = replacer(result);
}
}
} }
result = result.replace(/export default /g, 'export '); result = result.replace(/export default /g, 'export ');
result = result.replace(/export declare /g, 'export '); result = result.replace(/export declare /g, 'export ');
......
...@@ -1152,6 +1152,9 @@ export interface IEditorCommentsOptions { ...@@ -1152,6 +1152,9 @@ export interface IEditorCommentsOptions {
ignoreEmptyLines?: boolean; ignoreEmptyLines?: boolean;
} }
/**
* @internal
*/
export type EditorCommentsOptions = Readonly<Required<IEditorCommentsOptions>>; export type EditorCommentsOptions = Readonly<Required<IEditorCommentsOptions>>;
class EditorComments extends BaseEditorOption<EditorOption.comments, EditorCommentsOptions> { class EditorComments extends BaseEditorOption<EditorOption.comments, EditorCommentsOptions> {
...@@ -1382,6 +1385,9 @@ export interface IEditorFindOptions { ...@@ -1382,6 +1385,9 @@ export interface IEditorFindOptions {
loop?: boolean; loop?: boolean;
} }
/**
* @internal
*/
export type EditorFindOptions = Readonly<Required<IEditorFindOptions>>; export type EditorFindOptions = Readonly<Required<IEditorFindOptions>>;
class EditorFind extends BaseEditorOption<EditorOption.find, EditorFindOptions> { class EditorFind extends BaseEditorOption<EditorOption.find, EditorFindOptions> {
...@@ -1634,6 +1640,9 @@ export interface IGotoLocationOptions { ...@@ -1634,6 +1640,9 @@ export interface IGotoLocationOptions {
alternativeReferenceCommand?: string; alternativeReferenceCommand?: string;
} }
/**
* @internal
*/
export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>; export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>;
class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, GoToLocationOptions> { class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, GoToLocationOptions> {
...@@ -1769,6 +1778,9 @@ export interface IEditorHoverOptions { ...@@ -1769,6 +1778,9 @@ export interface IEditorHoverOptions {
sticky?: boolean; sticky?: boolean;
} }
/**
* @internal
*/
export type EditorHoverOptions = Readonly<Required<IEditorHoverOptions>>; export type EditorHoverOptions = Readonly<Required<IEditorHoverOptions>>;
class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOptions> { class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOptions> {
...@@ -2390,6 +2402,9 @@ export interface IEditorLightbulbOptions { ...@@ -2390,6 +2402,9 @@ export interface IEditorLightbulbOptions {
enabled?: boolean; enabled?: boolean;
} }
/**
* @internal
*/
export type EditorLightbulbOptions = Readonly<Required<IEditorLightbulbOptions>>; export type EditorLightbulbOptions = Readonly<Required<IEditorLightbulbOptions>>;
class EditorLightbulb extends BaseEditorOption<EditorOption.lightbulb, EditorLightbulbOptions> { class EditorLightbulb extends BaseEditorOption<EditorOption.lightbulb, EditorLightbulbOptions> {
...@@ -2446,6 +2461,9 @@ export interface IEditorInlayHintsOptions { ...@@ -2446,6 +2461,9 @@ export interface IEditorInlayHintsOptions {
fontFamily?: string; fontFamily?: string;
} }
/**
* @internal
*/
export type EditorInlayHintsOptions = Readonly<Required<IEditorInlayHintsOptions>>; export type EditorInlayHintsOptions = Readonly<Required<IEditorInlayHintsOptions>>;
class EditorInlayHints extends BaseEditorOption<EditorOption.inlayHints, EditorInlayHintsOptions> { class EditorInlayHints extends BaseEditorOption<EditorOption.inlayHints, EditorInlayHintsOptions> {
...@@ -2554,6 +2572,9 @@ export interface IEditorMinimapOptions { ...@@ -2554,6 +2572,9 @@ export interface IEditorMinimapOptions {
scale?: number; scale?: number;
} }
/**
* @internal
*/
export type EditorMinimapOptions = Readonly<Required<IEditorMinimapOptions>>; export type EditorMinimapOptions = Readonly<Required<IEditorMinimapOptions>>;
class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimapOptions> { class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimapOptions> {
...@@ -2667,10 +2688,10 @@ export interface IEditorPaddingOptions { ...@@ -2667,10 +2688,10 @@ export interface IEditorPaddingOptions {
bottom?: number; bottom?: number;
} }
export interface InternalEditorPaddingOptions { /**
readonly top: number; * @internal
readonly bottom: number; */
} export type InternalEditorPaddingOptions = Readonly<Required<IEditorPaddingOptions>>;
class EditorPadding extends BaseEditorOption<EditorOption.padding, InternalEditorPaddingOptions> { class EditorPadding extends BaseEditorOption<EditorOption.padding, InternalEditorPaddingOptions> {
...@@ -2728,6 +2749,9 @@ export interface IEditorParameterHintOptions { ...@@ -2728,6 +2749,9 @@ export interface IEditorParameterHintOptions {
cycle?: boolean; cycle?: boolean;
} }
/**
* @internal
*/
export type InternalParameterHintOptions = Readonly<Required<IEditorParameterHintOptions>>; export type InternalParameterHintOptions = Readonly<Required<IEditorParameterHintOptions>>;
class EditorParameterHints extends BaseEditorOption<EditorOption.parameterHints, InternalParameterHintOptions> { class EditorParameterHints extends BaseEditorOption<EditorOption.parameterHints, InternalParameterHintOptions> {
...@@ -2794,6 +2818,9 @@ export interface IQuickSuggestionsOptions { ...@@ -2794,6 +2818,9 @@ export interface IQuickSuggestionsOptions {
strings?: boolean; strings?: boolean;
} }
/**
* @internal
*/
export type ValidQuickSuggestionsOptions = boolean | Readonly<Required<IQuickSuggestionsOptions>>; export type ValidQuickSuggestionsOptions = boolean | Readonly<Required<IQuickSuggestionsOptions>>;
class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggestions, ValidQuickSuggestionsOptions> { class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggestions, ValidQuickSuggestionsOptions> {
...@@ -3226,6 +3253,9 @@ export interface IInlineSuggestOptions { ...@@ -3226,6 +3253,9 @@ export interface IInlineSuggestOptions {
mode?: 'prefix' | 'subword' | 'subwordSmart'; mode?: 'prefix' | 'subword' | 'subwordSmart';
} }
/**
* @internal
*/
export type InternalInlineSuggestOptions = Readonly<Required<IInlineSuggestOptions>>; export type InternalInlineSuggestOptions = Readonly<Required<IInlineSuggestOptions>>;
/** /**
...@@ -3273,6 +3303,9 @@ export interface IBracketPairColorizationOptions { ...@@ -3273,6 +3303,9 @@ export interface IBracketPairColorizationOptions {
enabled?: boolean; enabled?: boolean;
} }
/**
* @internal
*/
export type InternalBracketPairColorizationOptions = Readonly<Required<IBracketPairColorizationOptions>>; export type InternalBracketPairColorizationOptions = Readonly<Required<IBracketPairColorizationOptions>>;
/** /**
...@@ -3330,6 +3363,9 @@ export interface IGuidesOptions { ...@@ -3330,6 +3363,9 @@ export interface IGuidesOptions {
highlightActiveIndentation?: boolean; highlightActiveIndentation?: boolean;
} }
/**
* @internal
*/
export type InternalGuidesOptions = Readonly<Required<IGuidesOptions>>; export type InternalGuidesOptions = Readonly<Required<IGuidesOptions>>;
/** /**
...@@ -3540,6 +3576,9 @@ export interface ISuggestOptions { ...@@ -3540,6 +3576,9 @@ export interface ISuggestOptions {
showSnippets?: boolean; showSnippets?: boolean;
} }
/**
* @internal
*/
export type InternalSuggestOptions = Readonly<Required<ISuggestOptions>>; export type InternalSuggestOptions = Readonly<Required<ISuggestOptions>>;
class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSuggestOptions> { class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSuggestOptions> {
...@@ -3851,6 +3890,9 @@ export interface ISmartSelectOptions { ...@@ -3851,6 +3890,9 @@ export interface ISmartSelectOptions {
selectLeadingAndTrailingWhitespace?: boolean selectLeadingAndTrailingWhitespace?: boolean
} }
/**
* @internal
*/
export type SmartSelectOptions = Readonly<Required<ISmartSelectOptions>>; export type SmartSelectOptions = Readonly<Required<ISmartSelectOptions>>;
class SmartSelect extends BaseEditorOption<EditorOption.smartSelect, SmartSelectOptions> { class SmartSelect extends BaseEditorOption<EditorOption.smartSelect, SmartSelectOptions> {
...@@ -4140,21 +4182,6 @@ export const enum EditorOption { ...@@ -4140,21 +4182,6 @@ export const enum EditorOption {
wrappingInfo, wrappingInfo,
} }
/**
* WORKAROUND: TS emits "any" for complex editor options values (anything except string, bool, enum, etc. ends up being "any")
* @monacodtsreplace
* /accessibilitySupport, any/accessibilitySupport, AccessibilitySupport/
* /comments, any/comments, EditorCommentsOptions/
* /find, any/find, EditorFindOptions/
* /fontInfo, any/fontInfo, FontInfo/
* /gotoLocation, any/gotoLocation, GoToLocationOptions/
* /hover, any/hover, EditorHoverOptions/
* /lightbulb, any/lightbulb, EditorLightbulbOptions/
* /minimap, any/minimap, EditorMinimapOptions/
* /parameterHints, any/parameterHints, InternalParameterHintOptions/
* /quickSuggestions, any/quickSuggestions, ValidQuickSuggestionsOptions/
* /suggest, any/suggest, InternalSuggestOptions/
*/
export const EditorOptions = { export const EditorOptions = {
acceptSuggestionOnCommitCharacter: register(new EditorBooleanOption( acceptSuggestionOnCommitCharacter: register(new EditorBooleanOption(
EditorOption.acceptSuggestionOnCommitCharacter, 'acceptSuggestionOnCommitCharacter', true, EditorOption.acceptSuggestionOnCommitCharacter, 'acceptSuggestionOnCommitCharacter', true,
......
...@@ -3377,8 +3377,6 @@ declare namespace monaco.editor { ...@@ -3377,8 +3377,6 @@ declare namespace monaco.editor {
ignoreEmptyLines?: boolean; ignoreEmptyLines?: boolean;
} }
export type EditorCommentsOptions = Readonly<Required<IEditorCommentsOptions>>;
/** /**
* The kind of animation in which the editor's cursor should be rendered. * The kind of animation in which the editor's cursor should be rendered.
*/ */
...@@ -3462,8 +3460,6 @@ declare namespace monaco.editor { ...@@ -3462,8 +3460,6 @@ declare namespace monaco.editor {
loop?: boolean; loop?: boolean;
} }
export type EditorFindOptions = Readonly<Required<IEditorFindOptions>>;
export type GoToLocationValues = 'peek' | 'gotoAndPeek' | 'goto'; export type GoToLocationValues = 'peek' | 'gotoAndPeek' | 'goto';
/** /**
...@@ -3483,8 +3479,6 @@ declare namespace monaco.editor { ...@@ -3483,8 +3479,6 @@ declare namespace monaco.editor {
alternativeReferenceCommand?: string; alternativeReferenceCommand?: string;
} }
export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>;
/** /**
* Configuration options for editor hover * Configuration options for editor hover
*/ */
...@@ -3506,8 +3500,6 @@ declare namespace monaco.editor { ...@@ -3506,8 +3500,6 @@ declare namespace monaco.editor {
sticky?: boolean; sticky?: boolean;
} }
export type EditorHoverOptions = Readonly<Required<IEditorHoverOptions>>;
/** /**
* A description for the overview ruler position. * A description for the overview ruler position.
*/ */
...@@ -3633,8 +3625,6 @@ declare namespace monaco.editor { ...@@ -3633,8 +3625,6 @@ declare namespace monaco.editor {
enabled?: boolean; enabled?: boolean;
} }
export type EditorLightbulbOptions = Readonly<Required<IEditorLightbulbOptions>>;
/** /**
* Configuration options for editor inlayHints * Configuration options for editor inlayHints
*/ */
...@@ -3656,8 +3646,6 @@ declare namespace monaco.editor { ...@@ -3656,8 +3646,6 @@ declare namespace monaco.editor {
fontFamily?: string; fontFamily?: string;
} }
export type EditorInlayHintsOptions = Readonly<Required<IEditorInlayHintsOptions>>;
/** /**
* Configuration options for editor minimap * Configuration options for editor minimap
*/ */
...@@ -3698,8 +3686,6 @@ declare namespace monaco.editor { ...@@ -3698,8 +3686,6 @@ declare namespace monaco.editor {
scale?: number; scale?: number;
} }
export type EditorMinimapOptions = Readonly<Required<IEditorMinimapOptions>>;
/** /**
* Configuration options for editor padding * Configuration options for editor padding
*/ */
...@@ -3714,11 +3700,6 @@ declare namespace monaco.editor { ...@@ -3714,11 +3700,6 @@ declare namespace monaco.editor {
bottom?: number; bottom?: number;
} }
export interface InternalEditorPaddingOptions {
readonly top: number;
readonly bottom: number;
}
/** /**
* Configuration options for parameter hints * Configuration options for parameter hints
*/ */
...@@ -3735,8 +3716,6 @@ declare namespace monaco.editor { ...@@ -3735,8 +3716,6 @@ declare namespace monaco.editor {
cycle?: boolean; cycle?: boolean;
} }
export type InternalParameterHintOptions = Readonly<Required<IEditorParameterHintOptions>>;
/** /**
* Configuration options for quick suggestions * Configuration options for quick suggestions
*/ */
...@@ -3746,8 +3725,6 @@ declare namespace monaco.editor { ...@@ -3746,8 +3725,6 @@ declare namespace monaco.editor {
strings?: boolean; strings?: boolean;
} }
export type ValidQuickSuggestionsOptions = boolean | Readonly<Required<IQuickSuggestionsOptions>>;
export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string);
export enum RenderLineNumbersType { export enum RenderLineNumbersType {
...@@ -3877,8 +3854,6 @@ declare namespace monaco.editor { ...@@ -3877,8 +3854,6 @@ declare namespace monaco.editor {
mode?: 'prefix' | 'subword' | 'subwordSmart'; mode?: 'prefix' | 'subword' | 'subwordSmart';
} }
export type InternalInlineSuggestOptions = Readonly<Required<IInlineSuggestOptions>>;
export interface IBracketPairColorizationOptions { export interface IBracketPairColorizationOptions {
/** /**
* Enable or disable bracket pair colorization. * Enable or disable bracket pair colorization.
...@@ -3886,8 +3861,6 @@ declare namespace monaco.editor { ...@@ -3886,8 +3861,6 @@ declare namespace monaco.editor {
enabled?: boolean; enabled?: boolean;
} }
export type InternalBracketPairColorizationOptions = Readonly<Required<IBracketPairColorizationOptions>>;
export interface IGuidesOptions { export interface IGuidesOptions {
/** /**
* Enable rendering of bracket pair guides. * Enable rendering of bracket pair guides.
...@@ -3905,8 +3878,6 @@ declare namespace monaco.editor { ...@@ -3905,8 +3878,6 @@ declare namespace monaco.editor {
highlightActiveIndentation?: boolean; highlightActiveIndentation?: boolean;
} }
export type InternalGuidesOptions = Readonly<Required<IGuidesOptions>>;
/** /**
* Configuration options for editor suggest widget * Configuration options for editor suggest widget
*/ */
...@@ -4065,14 +4036,10 @@ declare namespace monaco.editor { ...@@ -4065,14 +4036,10 @@ declare namespace monaco.editor {
showSnippets?: boolean; showSnippets?: boolean;
} }
export type InternalSuggestOptions = Readonly<Required<ISuggestOptions>>;
export interface ISmartSelectOptions { export interface ISmartSelectOptions {
selectLeadingAndTrailingWhitespace?: boolean; selectLeadingAndTrailingWhitespace?: boolean;
} }
export type SmartSelectOptions = Readonly<Required<ISmartSelectOptions>>;
/** /**
* Describes how to indent wrapped lines. * Describes how to indent wrapped lines.
*/ */
...@@ -4235,6 +4202,7 @@ declare namespace monaco.editor { ...@@ -4235,6 +4202,7 @@ declare namespace monaco.editor {
layoutInfo = 129, layoutInfo = 129,
wrappingInfo = 130 wrappingInfo = 130
} }
export const EditorOptions: { export const EditorOptions: {
acceptSuggestionOnCommitCharacter: IEditorOption<EditorOption.acceptSuggestionOnCommitCharacter, boolean>; acceptSuggestionOnCommitCharacter: IEditorOption<EditorOption.acceptSuggestionOnCommitCharacter, boolean>;
acceptSuggestionOnEnter: IEditorOption<EditorOption.acceptSuggestionOnEnter, 'on' | 'off' | 'smart'>; acceptSuggestionOnEnter: IEditorOption<EditorOption.acceptSuggestionOnEnter, 'on' | 'off' | 'smart'>;
...@@ -4310,11 +4278,11 @@ declare namespace monaco.editor { ...@@ -4310,11 +4278,11 @@ declare namespace monaco.editor {
occurrencesHighlight: IEditorOption<EditorOption.occurrencesHighlight, boolean>; occurrencesHighlight: IEditorOption<EditorOption.occurrencesHighlight, boolean>;
overviewRulerBorder: IEditorOption<EditorOption.overviewRulerBorder, boolean>; overviewRulerBorder: IEditorOption<EditorOption.overviewRulerBorder, boolean>;
overviewRulerLanes: IEditorOption<EditorOption.overviewRulerLanes, number>; overviewRulerLanes: IEditorOption<EditorOption.overviewRulerLanes, number>;
padding: IEditorOption<EditorOption.padding, InternalEditorPaddingOptions>; padding: IEditorOption<EditorOption.padding, Readonly<Required<IEditorPaddingOptions>>>;
parameterHints: IEditorOption<EditorOption.parameterHints, Readonly<Required<IEditorParameterHintOptions>>>; parameterHints: IEditorOption<EditorOption.parameterHints, Readonly<Required<IEditorParameterHintOptions>>>;
peekWidgetDefaultFocus: IEditorOption<EditorOption.peekWidgetDefaultFocus, 'tree' | 'editor'>; peekWidgetDefaultFocus: IEditorOption<EditorOption.peekWidgetDefaultFocus, 'tree' | 'editor'>;
definitionLinkOpensInPeek: IEditorOption<EditorOption.definitionLinkOpensInPeek, boolean>; definitionLinkOpensInPeek: IEditorOption<EditorOption.definitionLinkOpensInPeek, boolean>;
quickSuggestions: IEditorOption<EditorOption.quickSuggestions, ValidQuickSuggestionsOptions>; quickSuggestions: IEditorOption<EditorOption.quickSuggestions, any>;
quickSuggestionsDelay: IEditorOption<EditorOption.quickSuggestionsDelay, number>; quickSuggestionsDelay: IEditorOption<EditorOption.quickSuggestionsDelay, number>;
readOnly: IEditorOption<EditorOption.readOnly, boolean>; readOnly: IEditorOption<EditorOption.readOnly, boolean>;
renameOnType: IEditorOption<EditorOption.renameOnType, boolean>; renameOnType: IEditorOption<EditorOption.renameOnType, boolean>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册