mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Co-authored-by: Armando Aguirre <armando.aguirre@microsoft.com>
This commit is contained in:
co-authored by
Armando Aguirre
parent
315f9f9a14
commit
3a7983a024
@@ -800,6 +800,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
type: "boolean",
|
||||
affectsEmit: true,
|
||||
affectsBuildInfo: true,
|
||||
affectsSourceFile: true,
|
||||
category: Diagnostics.Emit,
|
||||
description: Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
|
||||
defaultValueDescription: false,
|
||||
@@ -1270,6 +1271,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
affectsEmit: true,
|
||||
affectsBuildInfo: true,
|
||||
affectsModuleResolution: true,
|
||||
affectsSourceFile: true,
|
||||
category: Diagnostics.Language_and_Environment,
|
||||
description: Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
|
||||
defaultValueDescription: "react",
|
||||
|
||||
@@ -198,6 +198,7 @@ export * from "./unittests/tsserver/pasteEdits.js";
|
||||
export * from "./unittests/tsserver/plugins.js";
|
||||
export * from "./unittests/tsserver/pluginsAsync.js";
|
||||
export * from "./unittests/tsserver/projectErrors.js";
|
||||
export * from "./unittests/tsserver/projectImportHelpers.js";
|
||||
export * from "./unittests/tsserver/projectReferenceCompileOnSave.js";
|
||||
export * from "./unittests/tsserver/projectReferenceErrors.js";
|
||||
export * from "./unittests/tsserver/projectReferences.js";
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import * as ts from "../../_namespaces/ts.js";
|
||||
import { jsonToReadableText } from "../helpers.js";
|
||||
import {
|
||||
baselineTsserverLogs,
|
||||
openFilesForSession,
|
||||
TestSession,
|
||||
} from "../helpers/tsserver.js";
|
||||
import { createServerHost } from "../helpers/virtualFileSystemWithWatch.js";
|
||||
|
||||
describe("unittests:: tsserver:: projectImportHelpers::", () => {
|
||||
it("import helpers sucessfully", () => {
|
||||
const type1 = {
|
||||
path: "/a/type.ts",
|
||||
content: `
|
||||
export type Foo {
|
||||
bar: number;
|
||||
};`,
|
||||
};
|
||||
const file1 = {
|
||||
path: "/a/file1.ts",
|
||||
content: `
|
||||
import { Foo } from "./type";
|
||||
const a: Foo = { bar : 1 };
|
||||
a.bar;`,
|
||||
};
|
||||
const file2 = {
|
||||
path: "/a/file2.ts",
|
||||
content: `
|
||||
import { Foo } from "./type";
|
||||
const a: Foo = { bar : 2 };
|
||||
a.bar;`,
|
||||
};
|
||||
|
||||
const config1 = {
|
||||
path: "/a/tsconfig.json",
|
||||
content: jsonToReadableText({
|
||||
extends: "../tsconfig.json",
|
||||
compilerOptions: {
|
||||
importHelpers: true,
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const file3 = {
|
||||
path: "/file3.js",
|
||||
content: "console.log('noop');",
|
||||
};
|
||||
const config2 = {
|
||||
path: "/tsconfig.json",
|
||||
content: jsonToReadableText({
|
||||
include: ["**/*"],
|
||||
}),
|
||||
};
|
||||
|
||||
const host = createServerHost([config2, config1, type1, file1, file2, file3]);
|
||||
const session = new TestSession(host);
|
||||
|
||||
openFilesForSession([file3, file1], session);
|
||||
|
||||
session.executeCommandSeq<ts.server.protocol.ReferencesRequest>({
|
||||
command: ts.server.protocol.CommandTypes.References,
|
||||
arguments: {
|
||||
file: file1.path,
|
||||
line: 4,
|
||||
offset: 3,
|
||||
},
|
||||
});
|
||||
|
||||
baselineTsserverLogs("importHelpers", "import helpers successfully", session);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user