-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add workspace implicit project defaults configuration (#605)
Also update implicit project configuration defaults to match vscode.
- Loading branch information
Showing
4 changed files
with
135 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
/* | ||
* Copyright (C) 2022 TypeFox and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
import tsp from 'typescript/lib/protocol.d.js'; | ||
import type { WorkspaceConfigurationImplicitProjectConfigurationOptions } from '../configuration-manager.js'; | ||
|
||
const DEFAULT_PROJECT_CONFIG: tsp.ExternalProjectCompilerOptions = Object.freeze({ | ||
module: tsp.ModuleKind.ESNext, | ||
moduleResolution: tsp.ModuleResolutionKind.Node, | ||
target: tsp.ScriptTarget.ES2020, | ||
jsx: tsp.JsxEmit.React, | ||
}); | ||
|
||
export function getInferredProjectCompilerOptions( | ||
workspaceConfig: WorkspaceConfigurationImplicitProjectConfigurationOptions, | ||
): tsp.ExternalProjectCompilerOptions { | ||
const projectConfig = { ...DEFAULT_PROJECT_CONFIG }; | ||
|
||
if (workspaceConfig.checkJs) { | ||
projectConfig.checkJs = true; | ||
} | ||
|
||
if (workspaceConfig.experimentalDecorators) { | ||
projectConfig.experimentalDecorators = true; | ||
} | ||
|
||
if (workspaceConfig.strictNullChecks) { | ||
projectConfig.strictNullChecks = true; | ||
} | ||
|
||
if (workspaceConfig.strictFunctionTypes) { | ||
projectConfig.strictFunctionTypes = true; | ||
} | ||
|
||
if (workspaceConfig.module) { | ||
projectConfig.module = workspaceConfig.module as tsp.ModuleKind; | ||
} | ||
|
||
if (workspaceConfig.target) { | ||
projectConfig.target = workspaceConfig.target as tsp.ScriptTarget; | ||
} | ||
|
||
projectConfig.sourceMap = true; | ||
|
||
return projectConfig; | ||
} |