From b4fe221e65d3ebba0e06f9562cb939574f80fe20 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 21 Nov 2023 11:50:51 -0800 Subject: [PATCH] Cherry-pick #56489 into release-5.3 (#56490) --- src/compiler/types.ts | 2 +- src/server/project.ts | 2 +- src/services/types.ts | 8 ++++---- tests/baselines/reference/api/typescript.d.ts | 2 +- tests/cases/compiler/APILibCheck.ts | 1 + 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5e44aac6dd25f..c33cafe7136c6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7404,7 +7404,7 @@ export interface CommandLineOptionBase { isFilePath?: boolean; // True if option value is a path or fileName shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' description?: DiagnosticMessage; // The message describing what the command line switch does. - defaultValueDescription?: string | number | boolean | DiagnosticMessage; // The message describing what the dafault value is. string type is prepared for fixed chosen like "false" which do not need I18n. + defaultValueDescription?: string | number | boolean | DiagnosticMessage | undefined; // The message describing what the dafault value is. string type is prepared for fixed chosen like "false" which do not need I18n. paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file isCommandLineOnly?: boolean; diff --git a/src/server/project.ts b/src/server/project.ts index e0a21ed7701d2..8eda935c575b4 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -347,7 +347,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo readonly realpath?: (path: string) => string; /** @internal */ - hasInvalidatedResolutions: HasInvalidatedResolutions | undefined; + hasInvalidatedResolutions?: HasInvalidatedResolutions | undefined; /** @internal */ hasInvalidatedLibResolutions: HasInvalidatedLibResolutions | undefined; diff --git a/src/services/types.ts b/src/services/types.ts index c1d92f808dccf..5758b4402cffc 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -337,7 +337,7 @@ export interface LanguageServiceHost extends GetEffectiveTypeRootsHost, MinimalR */ readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; realpath?(path: string): string; - /** @internal */ createHash?(data: string): string; + /** @internal */ createHash?: ((data: string) => string) | undefined; /* * Unlike `realpath and `readDirectory`, `readFile` and `fileExists` are now _required_ @@ -390,9 +390,9 @@ export interface LanguageServiceHost extends GetEffectiveTypeRootsHost, MinimalR * If provided along with custom resolveLibrary, used to determine if we should redo library resolutions * @internal */ - hasInvalidatedLibResolutions?(libFileName: string): boolean; + hasInvalidatedLibResolutions?: ((libFileName: string) => boolean) | undefined; - /** @internal */ hasInvalidatedResolutions?: HasInvalidatedResolutions; + /** @internal */ hasInvalidatedResolutions?: HasInvalidatedResolutions | undefined; /** @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames; /** @internal */ getGlobalTypingsCacheLocation?(): string | undefined; /** @internal */ getSymlinkCache?(files?: readonly SourceFile[]): SymlinkCache; @@ -429,7 +429,7 @@ export interface LanguageServiceHost extends GetEffectiveTypeRootsHost, MinimalR /** @internal */ onReleaseParsedCommandLine?(configFileName: string, oldResolvedRef: ResolvedProjectReference | undefined, optionOptions: CompilerOptions): void; /** @internal */ getIncompleteCompletionsCache?(): IncompleteCompletionsCache; - jsDocParsingMode?: JSDocParsingMode; + jsDocParsingMode?: JSDocParsingMode | undefined; } /** @internal */ diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index f9df3aaa3d430..986c17630bfe2 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -10418,7 +10418,7 @@ declare namespace ts { installPackage?(options: InstallPackageOptions): Promise; writeFile?(fileName: string, content: string): void; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; - jsDocParsingMode?: JSDocParsingMode; + jsDocParsingMode?: JSDocParsingMode | undefined; } type WithMetadata = T & { metadata?: unknown; diff --git a/tests/cases/compiler/APILibCheck.ts b/tests/cases/compiler/APILibCheck.ts index 674c2f280a1ea..38821a58b0b76 100644 --- a/tests/cases/compiler/APILibCheck.ts +++ b/tests/cases/compiler/APILibCheck.ts @@ -2,6 +2,7 @@ // @noImplicitAny: true // @strictNullChecks: true // @lib: es2018 +// @exactOptionalPropertyTypes: true // @filename: node_modules/typescript/package.json {