Skip to content

Commit 5434c41

Browse files
author
Armando Aguirre
committed
Added deferred project context test, marked JsFileExtension as deprecated
1 parent db08a77 commit 5434c41

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,6 +4067,7 @@ namespace ts {
40674067
Prototype,
40684068
}
40694069

4070+
/** @deprecated Use FileExtensionInfo instead. */
40704071
export type JsFileExtensionInfo = FileExtensionInfo;
40714072

40724073
export interface FileExtensionInfo {

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,6 +3135,48 @@ namespace ts.projectSystem {
31353135
});
31363136

31373137
});
3138+
3139+
it("includes deferred files in the project context", () => {
3140+
const file1 = {
3141+
path: "/a.deferred",
3142+
content: "const a = 1;"
3143+
};
3144+
// Deferred extensions should not affect JS files.
3145+
const file2 = {
3146+
path: "/b.js",
3147+
content: "const b = 1;"
3148+
};
3149+
const tsconfig = {
3150+
path: "/tsconfig.json",
3151+
content: ""
3152+
};
3153+
3154+
const host = createServerHost([file1, file2, tsconfig]);
3155+
const session = createSession(host);
3156+
const projectService = session.getProjectService();
3157+
3158+
// Configure the deferred extension.
3159+
const extraFileExtensions = [{ extension: ".deferred", scriptKind: ScriptKind.Deferred, isMixedContent: true }];
3160+
const configureHostRequest = makeSessionRequest<protocol.ConfigureRequestArguments>(CommandNames.Configure, { extraFileExtensions });
3161+
session.executeCommand(configureHostRequest);
3162+
3163+
// Open external project
3164+
const projectName = "/proj1";
3165+
projectService.openExternalProject({
3166+
projectFileName: projectName,
3167+
rootFiles: toExternalFiles([file1.path, file2.path, tsconfig.path]),
3168+
options: {}
3169+
});
3170+
3171+
// Assert
3172+
checkNumberOfProjects(projectService, { configuredProjects: 1 });
3173+
3174+
const configuredProject = configuredProjectAt(projectService, 0);
3175+
checkProjectActualFiles(configuredProject, [file1.path, tsconfig.path]);
3176+
3177+
// Allow allowNonTsExtensions will be set to true for deferred extensions.
3178+
assert.isTrue(configuredProject.getCompilerOptions().allowNonTsExtensions);
3179+
});
31383180
});
31393181

31403182
describe("tsserverProjectSystem Proper errors", () => {

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,6 +2266,7 @@ declare namespace ts {
22662266
AlwaysStrict = 64,
22672267
PriorityImpliesCombination = 28
22682268
}
2269+
/** @deprecated Use FileExtensionInfo instead. */
22692270
type JsFileExtensionInfo = FileExtensionInfo;
22702271
interface FileExtensionInfo {
22712272
extension: string;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,6 +2266,7 @@ declare namespace ts {
22662266
AlwaysStrict = 64,
22672267
PriorityImpliesCombination = 28
22682268
}
2269+
/** @deprecated Use FileExtensionInfo instead. */
22692270
type JsFileExtensionInfo = FileExtensionInfo;
22702271
interface FileExtensionInfo {
22712272
extension: string;

0 commit comments

Comments
 (0)