mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-23 19:59:37 +00:00
Use esnext as implicit js/ts module
For https://github.com/microsoft/TypeScript/issues/46698 Also adds new settings for the target and module in implicit projects
This commit is contained in:
@@ -52,12 +52,16 @@ export const enum SyntaxServerConfiguration {
|
||||
|
||||
export class ImplicitProjectConfiguration {
|
||||
|
||||
public readonly target: string | undefined;
|
||||
public readonly module: string | undefined;
|
||||
public readonly checkJs: boolean;
|
||||
public readonly experimentalDecorators: boolean;
|
||||
public readonly strictNullChecks: boolean;
|
||||
public readonly strictFunctionTypes: boolean;
|
||||
|
||||
constructor(configuration: vscode.WorkspaceConfiguration) {
|
||||
this.target = ImplicitProjectConfiguration.readTarget(configuration);
|
||||
this.module = ImplicitProjectConfiguration.readModule(configuration);
|
||||
this.checkJs = ImplicitProjectConfiguration.readCheckJs(configuration);
|
||||
this.experimentalDecorators = ImplicitProjectConfiguration.readExperimentalDecorators(configuration);
|
||||
this.strictNullChecks = ImplicitProjectConfiguration.readImplicitStrictNullChecks(configuration);
|
||||
@@ -68,6 +72,14 @@ export class ImplicitProjectConfiguration {
|
||||
return objects.equals(this, other);
|
||||
}
|
||||
|
||||
private static readTarget(configuration: vscode.WorkspaceConfiguration): string | undefined {
|
||||
return configuration.get<string>('js/ts.implicitProjectConfig.target');
|
||||
}
|
||||
|
||||
private static readModule(configuration: vscode.WorkspaceConfiguration): string | undefined {
|
||||
return configuration.get<string>('js/ts.implicitProjectConfig.module');
|
||||
}
|
||||
|
||||
private static readCheckJs(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('js/ts.implicitProjectConfig.checkJs')
|
||||
?? configuration.get<boolean>('javascript.implicitProjectConfig.checkJs', false);
|
||||
|
||||
@@ -22,15 +22,18 @@ export function isImplicitProjectConfigFile(configFileName: string) {
|
||||
return configFileName.startsWith('/dev/null/');
|
||||
}
|
||||
|
||||
const defaultProjectConfig = Object.freeze<Proto.ExternalProjectCompilerOptions>({
|
||||
module: 'ESNext' as Proto.ModuleKind,
|
||||
moduleResolution: 'Node' as Proto.ModuleResolutionKind,
|
||||
target: 'ES2020' as Proto.ScriptTarget,
|
||||
jsx: 'Preserve' as Proto.JsxEmit,
|
||||
});
|
||||
|
||||
export function inferredProjectCompilerOptions(
|
||||
projectType: ProjectType,
|
||||
serviceConfig: TypeScriptServiceConfiguration,
|
||||
): Proto.ExternalProjectCompilerOptions {
|
||||
const projectConfig: Proto.ExternalProjectCompilerOptions = {
|
||||
module: 'commonjs' as Proto.ModuleKind,
|
||||
target: 'es2020' as Proto.ScriptTarget,
|
||||
jsx: 'preserve' as Proto.JsxEmit,
|
||||
};
|
||||
const projectConfig = { ...defaultProjectConfig };
|
||||
|
||||
if (serviceConfig.implicitProjectConfiguration.checkJs) {
|
||||
projectConfig.checkJs = true;
|
||||
@@ -51,6 +54,15 @@ export function inferredProjectCompilerOptions(
|
||||
projectConfig.strictFunctionTypes = true;
|
||||
}
|
||||
|
||||
|
||||
if (serviceConfig.implicitProjectConfiguration.module) {
|
||||
projectConfig.module = serviceConfig.implicitProjectConfiguration.module as Proto.ModuleKind;
|
||||
}
|
||||
|
||||
if (serviceConfig.implicitProjectConfiguration.target) {
|
||||
projectConfig.target = serviceConfig.implicitProjectConfiguration.target as Proto.ScriptTarget;
|
||||
}
|
||||
|
||||
if (projectType === ProjectType.TypeScript) {
|
||||
projectConfig.sourceMap = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user