mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'main' into server-vfs-support
This commit is contained in:
@@ -3548,7 +3548,7 @@ namespace ts {
|
||||
}
|
||||
if (isImplicitGlob(spec.substring(spec.lastIndexOf(directorySeparator) + 1))) {
|
||||
return {
|
||||
key: useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec),
|
||||
key: removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec)),
|
||||
flags: WatchDirectoryFlags.Recursive
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1288,18 +1288,22 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
const jsOnlyExtensions = [Extensions.JavaScript];
|
||||
const tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
||||
const tsPlusJsonExtensions = [...tsExtensions, Extensions.Json];
|
||||
const tsconfigExtensions = [Extensions.TSConfig];
|
||||
function nodeNextModuleNameResolverWorker(features: NodeResolutionFeatures, moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations {
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
|
||||
// es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
|
||||
const esmMode = resolutionMode === ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
|
||||
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
|
||||
let extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
|
||||
if (compilerOptions.resolveJsonModule) {
|
||||
extensions = [...extensions, Extensions.Json];
|
||||
}
|
||||
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
|
||||
}
|
||||
|
||||
const jsOnlyExtensions = [Extensions.JavaScript];
|
||||
const tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
||||
const tsPlusJsonExtensions = [...tsExtensions, Extensions.Json];
|
||||
const tsconfigExtensions = [Extensions.TSConfig];
|
||||
function tryResolveJSModuleWorker(moduleName: string, initialDir: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
||||
}
|
||||
|
||||
@@ -8813,6 +8813,7 @@ namespace ts {
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean,
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
|
||||
@@ -700,6 +700,7 @@ namespace ts {
|
||||
|
||||
function reloadFileNamesFromConfigFile() {
|
||||
writeLog("Reloading new file names and options");
|
||||
reloadLevel = ConfigFileProgramReloadLevel.None;
|
||||
rootFileNames = getFileNamesFromConfigSpecs(compilerOptions.configFile!.configFileSpecs!, getNormalizedAbsolutePath(getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
|
||||
if (updateErrorForNoInputFiles(rootFileNames, getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile!.configFileSpecs!, configFileParsingDiagnostics!, canConfigFileJsonReportNoInputFiles)) {
|
||||
hasChangedConfigFileParsingErrors = true;
|
||||
|
||||
@@ -729,7 +729,7 @@ namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
// All we need is the `success` and `message` fields of Response.
|
||||
export interface ApplyCodeActionCommandResponse extends Response {}
|
||||
export interface ApplyCodeActionCommandResponse extends Response { }
|
||||
|
||||
export interface FileRangeRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
@@ -1068,7 +1068,7 @@ namespace ts.server.protocol {
|
||||
readonly arguments: JsxClosingTagRequestArgs;
|
||||
}
|
||||
|
||||
export interface JsxClosingTagRequestArgs extends FileLocationRequestArgs {}
|
||||
export interface JsxClosingTagRequestArgs extends FileLocationRequestArgs { }
|
||||
|
||||
export interface JsxClosingTagResponse extends Response {
|
||||
readonly body: TextInsertion;
|
||||
@@ -2420,7 +2420,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* Human-readable description of the `source` from the CompletionEntry.
|
||||
*/
|
||||
sourceDisplay?: SymbolDisplayPart[];
|
||||
sourceDisplay?: SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
/** @deprecated Prefer CompletionInfoResponse, which supports several top-level fields in addition to the array of entries. */
|
||||
@@ -3445,7 +3445,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`.
|
||||
*/
|
||||
readonly includeCompletionsWithSnippetText?: boolean;
|
||||
readonly includeCompletionsWithSnippetText?: boolean;
|
||||
/**
|
||||
* If enabled, the completion list will include completions with invalid identifier names.
|
||||
* For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`.
|
||||
@@ -3495,6 +3495,7 @@ namespace ts.server.protocol {
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean,
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
|
||||
@@ -137,6 +137,10 @@ namespace ts.InlayHints {
|
||||
|
||||
const typeDisplayString = printTypeInSingleLine(declarationType);
|
||||
if (typeDisplayString) {
|
||||
const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
|
||||
if (isVariableNameMatchesType) {
|
||||
return;
|
||||
}
|
||||
addTypeHints(typeDisplayString, decl.name.end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,5 +421,14 @@ namespace ts {
|
||||
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo.bar");
|
||||
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo.bar/src": WatchDirectoryFlags.Recursive });
|
||||
});
|
||||
|
||||
it("correctly parses wild card directories from implicit glob when two keys differ only in directory seperator", () => {
|
||||
const parsed = parseConfigFileTextToJson("/foo.bar/tsconfig.json", JSON.stringify({
|
||||
include: ["./", "./**/*.json"]
|
||||
}));
|
||||
|
||||
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo");
|
||||
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo": WatchDirectoryFlags.Recursive });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -616,6 +616,39 @@ export class A {
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "correctly parses wild card directories from implicit glob when two keys differ only in directory seperator",
|
||||
commandLineArgs: ["-w", "--extendedDiagnostics"],
|
||||
sys: () => {
|
||||
const file1 = {
|
||||
path: `${projectRoot}/f1.ts`,
|
||||
content: "export const x = 1"
|
||||
};
|
||||
const file2 = {
|
||||
path: `${projectRoot}/f2.ts`,
|
||||
content: "export const y = 1"
|
||||
};
|
||||
const configFile = {
|
||||
path: `${projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({ compilerOptions: { composite: true }, include: ["./", "./**/*.json"] })
|
||||
};
|
||||
return createWatchedSystem([file1, file2, libFile, configFile], { currentDirectory: projectRoot });
|
||||
},
|
||||
changes: [
|
||||
{
|
||||
caption: "Add new file",
|
||||
change: sys => sys.writeFile(`${projectRoot}/new-file.ts`, "export const z = 1;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Import new file",
|
||||
change: sys => sys.prependFile(`${projectRoot}/f1.ts`, `import { z } from "./new-file";`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "can correctly update configured project when set of root files has changed through include",
|
||||
|
||||
Reference in New Issue
Block a user