Skip to content

Commit

Permalink
Merge 4e8613f into ed17a89
Browse files Browse the repository at this point in the history
  • Loading branch information
armanio123 authored and typescript-bot committed Jul 10, 2024
1 parent f0e9921 commit 5e34447
Show file tree
Hide file tree
Showing 6 changed files with 990 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/testRunner/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
71 changes: 71 additions & 0 deletions src/testRunner/unittests/tsserver/projectImportHelpers.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ ScriptInfos::
/user/username/projects/myproject/tsconfig.json
DocumentRegistry::
Key:: undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined
Key:: undefined|undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined|undefined
/user/username/projects/myproject/index.ts: TS 1
/user/username/projects/myproject/module1.d.ts: TS 1
/a/lib/lib.d.ts: TS 1
Expand Down Expand Up @@ -254,7 +254,7 @@ Info seq [hh:mm:ss:mss] Files (2)
Info seq [hh:mm:ss:mss] -----------------------------------------------
DocumentRegistry::
Key:: undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined
Key:: undefined|undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined|undefined
/user/username/projects/myproject/index.ts: TS 1
/a/lib/lib.d.ts: TS 1
Info seq [hh:mm:ss:mss] FileWatcher:: Triggered with /user/username/projects/myproject/module1.d.ts 1:: WatchInfo: /user/username/projects/myproject/module1.d.ts 500 undefined WatchType: Closed Script info
Expand Down Expand Up @@ -344,7 +344,7 @@ Info seq [hh:mm:ss:mss] Files (3)

Info seq [hh:mm:ss:mss] -----------------------------------------------
DocumentRegistry::
Key:: undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined
Key:: undefined|undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined|undefined
/user/username/projects/myproject/index.ts: TS 1
/a/lib/lib.d.ts: TS 1
/user/username/projects/myproject/module1.d.ts: TS 1
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ ScriptInfos::
/user/username/projects/myproject/tsconfig.json
DocumentRegistry::
Key:: undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined
Key:: undefined|undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined|undefined
/user/username/projects/myproject/index.ts: TS 1
/user/username/projects/myproject/module1.d.ts: TS 1
/a/lib/lib.d.ts: TS 1
Expand Down Expand Up @@ -254,7 +254,7 @@ Info seq [hh:mm:ss:mss] Files (2)
Info seq [hh:mm:ss:mss] -----------------------------------------------
DocumentRegistry::
Key:: undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined
Key:: undefined|undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined|undefined
/user/username/projects/myproject/index.ts: TS 1
/a/lib/lib.d.ts: TS 1
Before request
Expand Down Expand Up @@ -336,7 +336,7 @@ Info seq [hh:mm:ss:mss] Files (3)

Info seq [hh:mm:ss:mss] -----------------------------------------------
DocumentRegistry::
Key:: undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined
Key:: undefined|undefined|undefined|undefined|false|undefined|undefined|undefined|undefined|undefined|undefined|undefined
/user/username/projects/myproject/index.ts: TS 1
/a/lib/lib.d.ts: TS 1
/user/username/projects/myproject/module1.d.ts: TS 1
Loading

0 comments on commit 5e34447

Please sign in to comment.