Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ linters:
depguard:
rules:
main:
files:
- '**/tsc/**/*.go'
deny:
- pkg: 'encoding/json$'
desc: 'Use "github.com/microsoft/TypeScript/tsc/internal/json" instead.'
Expand Down
21 changes: 21 additions & 0 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,28 @@ export const generateSync = task({
run: runGenerateSync,
});

async function runGeneratePreferences() {
await runGoGenerator("generate:preferences", {
file: "tsc/internal/ls/lsutil/userpreferences.go",
cwd: __dirname,
inputs: ["tools/userPreferences.schema.json", "tools/gen-preferences/*.go"],
exclude: ["**/*_test.go"],
envInputs: [],
outputs: [
"tsc/internal/ls/lsutil/userpreferences_generated.go",
"packages/typescript/src/api/userPreferences.generated.ts",
],
commands: [
["go", "-C", "./tools", "run", "./gen-preferences", "./userPreferences.schema.json", "../tsc/internal/ls/lsutil/userpreferences_generated.go", "../packages/typescript/src/api/userPreferences.generated.ts"],
["dprint", "fmt", "tsc/internal/ls/lsutil/userpreferences_generated.go", "packages/typescript/src/api/userPreferences.generated.ts"],
],
});
}

export const generatePreferences = goGenerateTask("generate:preferences", runGeneratePreferences);

async function runGenerateAPI() {
await runGeneratePreferences();
await runGoGenerator("generate:api", {
file: "tsc/internal/api/proto.go",
cwd: __dirname,
Expand Down
4 changes: 4 additions & 0 deletions packages/typescript/src/api/async/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import type {
CleanBuildResponse,
CompactSymbolReference,
CompilerOptions,
CompletionPreferences,
ConfiguredProjectId,
CreateBuildOrchestratorResponse,
CreateProgramOptions as ProtocolCreateProgramOptions,
Expand Down Expand Up @@ -109,6 +110,7 @@ import type {
TypePropertyMethod,
TypeResponse,
TypesPropertyMethod,
UserPreferences,
} from "../proto.ts";
import {
resolveFileName,
Expand Down Expand Up @@ -191,6 +193,7 @@ export type {
CompletionEntry,
CompletionInfo,
CompletionOptions,
CompletionPreferences,
ConditionalType,
ConfiguredProjectId,
CreateSourceFileOptions,
Expand Down Expand Up @@ -253,6 +256,7 @@ export type {
TypeReference,
UnionOrIntersectionType,
UnionType,
UserPreferences,
};

export interface ModuleResolverOptions {
Expand Down
5 changes: 5 additions & 0 deletions packages/typescript/src/api/proto.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ScriptKind } from "#enums/scriptKind";
import { ScriptTarget } from "#enums/scriptTarget";
import { SymbolOwnerKind } from "#enums/symbolOwnerKind";
import type { Path } from "../ast/index.ts";
import type { UserPreferences } from "./userPreferences.generated.ts";

export { JsxEmit } from "#enums/jsxEmit";
export { ModuleDetectionKind } from "#enums/moduleDetectionKind";
Expand Down Expand Up @@ -262,6 +263,10 @@ export interface InitializeResponse {

/** CreateSnapshotParams are the parameters for creating a new independent snapshot. */
export interface CreateSnapshotParams extends SnapshotRequestChangesParams {
/** UserPreferences configures language service behavior in the new snapshot. */
userPreferences?: UserPreferences | undefined;
/** PrepareAutoImports identifies the file whose auto-import indexes should be ready in the new snapshot. */
prepareAutoImports?: DocumentIdentifier | undefined;
/** FileNotifications describes host file system changes to invalidate while creating the snapshot. */
fileNotifications?: FileNotifications | undefined;
/**
Expand Down
1 change: 1 addition & 0 deletions packages/typescript/src/api/proto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type { ConfigFileResponse as ParsedCommandLine, DiagnosticResponse as Dia
export type { ProtocolSymbolResponse };

export * from "./proto.generated.ts";
export * from "./userPreferences.generated.ts";
Comment thread
andrewbranch marked this conversation as resolved.

export interface FileSymbolOwner {
readonly kind: typeof SymbolOwnerKind.File;
Expand Down
4 changes: 4 additions & 0 deletions packages/typescript/src/api/sync/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import type {
CleanBuildResponse,
CompactSymbolReference,
CompilerOptions,
CompletionPreferences,
ConfiguredProjectId,
CreateBuildOrchestratorResponse,
CreateProgramOptions as ProtocolCreateProgramOptions,
Expand Down Expand Up @@ -126,6 +127,7 @@ import type {
TypePropertyMethod,
TypeResponse,
TypesPropertyMethod,
UserPreferences,
} from "../proto.ts";
import {
resolveFileName,
Expand Down Expand Up @@ -208,6 +210,7 @@ export type {
CompletionEntry,
CompletionInfo,
CompletionOptions,
CompletionPreferences,
ConditionalType,
ConfiguredProjectId,
CreateSourceFileOptions,
Expand Down Expand Up @@ -270,6 +273,7 @@ export type {
TypeReference,
UnionOrIntersectionType,
UnionType,
UserPreferences,
};

export interface ModuleResolverOptions {
Expand Down
201 changes: 201 additions & 0 deletions packages/typescript/src/api/userPreferences.generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
// Code generated by gen-preferences from tools/userPreferences.schema.json; DO NOT EDIT.

export interface CodeLensUserPreferences {
implementationsCodeLensEnabled?: boolean | undefined;
implementationsCodeLensShowOnAllClassMethods?: boolean | undefined;
implementationsCodeLensShowOnInterfaceMethods?: boolean | undefined;
referencesCodeLensEnabled?: boolean | undefined;
referencesCodeLensShowOnAllFunctions?: boolean | undefined;
}

/**
* CompletionPreferences contains preferences used while producing completions.
*/
export interface CompletionPreferences {
/**
* Unless this option is `false`, member completion lists triggered with `.` will include entries
* on potentially-null and potentially-undefined values, with insertion text to replace
* preceding `.` tokens with `?.`.
*/
includeAutomaticOptionalChainCompletions?: boolean | undefined;
/**
* Enables auto-import-style completions on partially-typed import statements. E.g., allows
* `import write|` to be completed to `import { writeResult } from "./utils.js"`.
*/
includeCompletionsForImportStatements?: boolean | undefined;
/**
* If enabled, TypeScript will search through all external modules' exports and add them to the completions list.
* This affects lone identifier completions but not completions on the right hand side of `obj.`.
*/
includeCompletionsForModuleExports?: boolean | undefined;
/**
* If enabled, completions for class members (e.g. methods and properties) will include
* a whole declaration for the member.
*/
includeCompletionsWithClassMemberSnippets?: boolean | undefined;
/**
* If enabled, object literal methods will have a method declaration completion entry in addition
* to the regular completion entry containing just the method name.
*/
includeCompletionsWithObjectLiteralMethodSnippets?: boolean | undefined;
jsxAttributeCompletionStyle?: "auto" | "braces" | "none" | undefined;
}

export interface EditorSettings {
baseIndentSize?: number | undefined;
convertTabsToSpaces?: boolean | undefined;
indentSize?: number | undefined;
indentStyle?: "none" | "block" | "smart" | undefined;
newLineCharacter?: string | undefined;
tabSize?: number | undefined;
trimTrailingWhitespace?: boolean | undefined;
}

export interface FormatCodeSettings extends EditorSettings {
indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean | undefined;
indentSwitchCase?: boolean | undefined;
insertSpaceAfterCommaDelimiter?: boolean | undefined;
insertSpaceAfterConstructor?: boolean | undefined;
insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean | undefined;
insertSpaceAfterKeywordsInControlFlowStatements?: boolean | undefined;
insertSpaceAfterOpeningAndBeforeClosingEmptyBraces?: boolean | undefined;
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean | undefined;
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean | undefined;
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean | undefined;
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean | undefined;
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean | undefined;
insertSpaceAfterSemicolonInForStatements?: boolean | undefined;
insertSpaceAfterTypeAssertion?: boolean | undefined;
insertSpaceBeforeAndAfterBinaryOperators?: boolean | undefined;
insertSpaceBeforeFunctionParenthesis?: boolean | undefined;
insertSpaceBeforeTypeAnnotation?: boolean | undefined;
placeOpenBraceOnNewLineForControlBlocks?: boolean | undefined;
placeOpenBraceOnNewLineForFunctions?: boolean | undefined;
semicolons?: "ignore" | "insert" | "remove" | undefined;
}

export interface InlayHintsPreferences {
includeInlayEnumMemberValueHints?: boolean | undefined;
includeInlayFunctionLikeReturnTypeHints?: boolean | undefined;
includeInlayFunctionParameterTypeHints?: boolean | undefined;
includeInlayParameterNameHints?: "none" | "literals" | "all" | undefined;
includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean | undefined;
includeInlayPropertyDeclarationTypeHints?: boolean | undefined;
includeInlayVariableTypeHints?: boolean | undefined;
includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean | undefined;
}

/**
* UserPreferences represents TypeScript language service preferences.
*/
export interface UserPreferences extends FormatCodeSettings, CompletionPreferences, InlayHintsPreferences, CodeLensUserPreferences {
allowRenameOfImportPath?: boolean | undefined;
allowTextChangesInNewFiles?: boolean | undefined;
autoClosingTags?: boolean | undefined;
autoImportEntrypointDirectorySearch?: boolean | undefined;
autoImportFileExcludePatterns?: string[] | undefined;
autoImportSpecifierExcludeRegexes?: string[] | undefined;
/**
* AutomaticTypeAcquisitionEnabled is the unified setting from tsserver.automaticTypeAcquisition.enabled under the js/ts section.
* When set, it takes precedence over DisableAutomaticTypeAcquisition.
*/
automaticTypeAcquisitionEnabled?: boolean | undefined;
completeJSDocs?: boolean | undefined;
/**
* CustomConfigFileName specifies a custom config file name to use before defaulting to tsconfig.json/jsconfig.json.
*/
customConfigFileName?: string | undefined;
/**
* DisableAutomaticTypeAcquisition is the deprecated setting from typescript.disableAutomaticTypeAcquisition.
*/
disableAutomaticTypeAcquisition?: boolean | undefined;
disableLineTextInReferences?: boolean | undefined;
disableSuggestions?: boolean | undefined;
displayPartsForJSDoc?: boolean | undefined;
excludeLibrarySymbolsInNavTo?: boolean | undefined;
formatEnabled?: boolean | undefined;
generateReturnInDocTemplate?: boolean | undefined;
/**
* Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js"
*/
importModuleSpecifierEnding?: "auto" | "minimal" | "index" | "js" | undefined;
importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative" | undefined;
lazyConfiguredProjectsFromExternalProject?: boolean | undefined;
locale?: string | undefined;
/**
* A positive integer indicating the maximum length of a hover text before it is truncated.
*
* Default: `500`
*/
maximumHoverLength?: number | undefined;
/**
* Indicates whether accents and other diacritic marks are considered unequal for the purpose of sorting.
*
* This preference is ignored if organizeImportsCollation is not `unicode`.
*
* Default: `true`
*/
organizeImportsAccentCollation?: boolean | undefined;
/**
* Indicates whether upper case or lower case should sort first.
*
* This permission is ignored if:
* - organizeImportsCollation is not `unicode`
* - organizeImportsIgnoreCase is `true`
* - organizeImportsIgnoreCase is `auto` and the auto-detected case sensitivity is case-insensitive.
*
* Default: `false`
*/
organizeImportsCaseFirst?: "default" | "lower" | "upper" | undefined;
/**
* Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value of their
* code points, or via "unicode" natural sorting. This implementation is locale-agnostic and approximates the practical
* import-sorting behavior rather than the full Unicode Collation Algorithm.
*
* Default: Ordinal
*/
organizeImportsCollation?: "ordinal" | "unicode" | undefined;
/**
* Indicates whether imports should be organized in a case-insensitive manner.
*
* If unspecified, case sensitivity is detected.
*/
organizeImportsIgnoreCase?: boolean | undefined;
/**
* Indicates the locale to use for "unicode" collation in legacy clients. This is accepted for compatibility, but
* currently ignored because organize-import sorting is deterministic and locale-agnostic.
*
* This preference is ignored if organizeImportsCollation is not `unicode`.
*
* Default: `"en"`
*/
organizeImportsLocale?: string | undefined;
/**
* Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate
* strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`.
*
* This preference is ignored if organizeImportsCollation is not `unicode`.
*
* Default: `false`
*/
organizeImportsNumericCollation?: boolean | undefined;
/**
* Indicates which deterministic preset should be used to sort imports.
* "auto" detects the existing ordinal case sensitivity where possible.
*/
organizeImportsSort?: "auto" | "ordinal" | "ordinalIgnoreCase" | "natural" | "naturalIgnoreCase" | undefined;
/**
* Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is type-only.
*
* Default: `auto`, which defaults to `last`
*/
organizeImportsTypeOrder?: "auto" | "last" | "inline" | "first" | undefined;
preferGoToSourceDefinition?: boolean | undefined;
preferTypeOnlyAutoImports?: boolean | undefined;
providePrefixAndSuffixTextForRename?: boolean | undefined;
provideRefactorNotApplicableReason?: boolean | undefined;
quotePreference?: "auto" | "double" | "single" | undefined;
reportStyleChecksAsWarnings?: boolean | undefined;
validateEnabled?: boolean | undefined;
workspaceSymbolsScope?: "allOpenProjects" | "currentProject" | undefined;
}
Loading
Loading