mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-24 03:35:38 +00:00
Add two new setting for strict null and strict funtion in js/ts that are implicit projects
For #109988 The new `js/ts.implicitProjectConfig.strictNullChecks` and `js/ts.implicitProjectConfig.strictFunctionTypes` control these settings in implict javascript and typescript files that are not contained in a jsconfig or tsconfig project. They are enabled by default for now so that we can collect feedback on them
This commit is contained in:
@@ -511,7 +511,20 @@
|
||||
"javascript.implicitProjectConfig.experimentalDecorators": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"markdownDescription": "%javascript.implicitProjectConfig.experimentalDecorators%",
|
||||
"markdownDescription": "%configuration.implicitProjectConfig.experimentalDecorators%",
|
||||
"scope": "window"
|
||||
},
|
||||
"js/ts.implicitProjectConfig.strictNullChecks": {
|
||||
"title": "",
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"markdownDescription": "%configuration.implicitProjectConfig.strictNullChecks%",
|
||||
"scope": "window"
|
||||
},
|
||||
"js/ts.implicitProjectConfig.strictFunctionTypes": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"markdownDescription": "%configuration.implicitProjectConfig.strictFunctionTypes%",
|
||||
"scope": "window"
|
||||
},
|
||||
"javascript.suggest.names": {
|
||||
|
||||
@@ -62,7 +62,9 @@
|
||||
"configuration.tsserver.maxTsServerMemory": "Set the maximum amount of memory (in MB) to allocate to the TypeScript server process",
|
||||
"configuration.tsserver.experimental.enableProjectDiagnostics": "(Experimental) Enables project wide error reporting.",
|
||||
"typescript.locale": "Sets the locale used to report JavaScript and TypeScript errors. Default of `null` uses VS Code's locale.",
|
||||
"javascript.implicitProjectConfig.experimentalDecorators": "Enable/disable `experimentalDecorators` for JavaScript files that are not part of a project. Existing `jsconfig.json` or `tsconfig.json` files override this setting.",
|
||||
"configuration.implicitProjectConfig.experimentalDecorators": "Enable/disable `experimentalDecorators` in JavaScript files that are not part of a project. Existing `jsconfig.json` or `tsconfig.json` files override this setting.",
|
||||
"configuration.implicitProjectConfig.strictNullChecks": "Enable/disable [strict null checks](https://www.typescriptlang.org/tsconfig#strictNullChecks) in JavaScript and TypeScript files that are not part of a project. Existing `jsconfig.json` or `tsconfig.json` files override this setting.",
|
||||
"configuration.implicitProjectConfig.strictFunctionTypes": "Enable/disable [strict function types](https://www.typescriptlang.org/tsconfig#strictFunctionTypes) in JavaScript and TypeScript files that are not part of a project. Existing `jsconfig.json` or `tsconfig.json` files override this setting.",
|
||||
"configuration.suggest.autoImports": "Enable/disable auto import suggestions.",
|
||||
"taskDefinition.tsconfig.description": "The tsconfig file that defines the TS build.",
|
||||
"javascript.suggestionActions.enabled": "Enable/disable suggestion diagnostics for JavaScript files in the editor.",
|
||||
|
||||
@@ -191,6 +191,8 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
if (this.serverState.type === ServerState.Type.Running) {
|
||||
if (this._configuration.checkJs !== oldConfiguration.checkJs
|
||||
|| this._configuration.experimentalDecorators !== oldConfiguration.experimentalDecorators
|
||||
|| this._configuration.implicitStrictNullChecks !== oldConfiguration.implicitStrictNullChecks
|
||||
|| this._configuration.implicitStrictFunctionTypes !== oldConfiguration.implicitStrictFunctionTypes
|
||||
) {
|
||||
this.setCompilerOptionsForInferredProjects(this._configuration);
|
||||
}
|
||||
|
||||
@@ -58,8 +58,12 @@ export class TypeScriptServiceConfiguration {
|
||||
public readonly npmLocation: string | null;
|
||||
public readonly tsServerLogLevel: TsServerLogLevel = TsServerLogLevel.Off;
|
||||
public readonly tsServerPluginPaths: readonly string[];
|
||||
|
||||
public readonly checkJs: boolean;
|
||||
public readonly experimentalDecorators: boolean;
|
||||
public readonly implicitStrictNullChecks: boolean;
|
||||
public readonly implicitStrictFunctionTypes: boolean;
|
||||
|
||||
public readonly disableAutomaticTypeAcquisition: boolean;
|
||||
public readonly separateSyntaxServer: SeparateSyntaxServerConfiguration;
|
||||
public readonly enableProjectDiagnostics: boolean;
|
||||
@@ -83,6 +87,8 @@ export class TypeScriptServiceConfiguration {
|
||||
this.tsServerPluginPaths = TypeScriptServiceConfiguration.readTsServerPluginPaths(configuration);
|
||||
this.checkJs = TypeScriptServiceConfiguration.readCheckJs(configuration);
|
||||
this.experimentalDecorators = TypeScriptServiceConfiguration.readExperimentalDecorators(configuration);
|
||||
this.implicitStrictNullChecks = TypeScriptServiceConfiguration.readImplicitStrictNullChecks(configuration);
|
||||
this.implicitStrictFunctionTypes = TypeScriptServiceConfiguration.readImplicitStrictFunctionTypes(configuration);
|
||||
this.disableAutomaticTypeAcquisition = TypeScriptServiceConfiguration.readDisableAutomaticTypeAcquisition(configuration);
|
||||
this.separateSyntaxServer = TypeScriptServiceConfiguration.readUseSeparateSyntaxServer(configuration);
|
||||
this.enableProjectDiagnostics = TypeScriptServiceConfiguration.readEnableProjectDiagnostics(configuration);
|
||||
@@ -100,6 +106,8 @@ export class TypeScriptServiceConfiguration {
|
||||
&& this.tsServerLogLevel === other.tsServerLogLevel
|
||||
&& this.checkJs === other.checkJs
|
||||
&& this.experimentalDecorators === other.experimentalDecorators
|
||||
&& this.implicitStrictNullChecks === other.implicitStrictNullChecks
|
||||
&& this.implicitStrictFunctionTypes === other.implicitStrictFunctionTypes
|
||||
&& this.disableAutomaticTypeAcquisition === other.disableAutomaticTypeAcquisition
|
||||
&& arrays.equals(this.tsServerPluginPaths, other.tsServerPluginPaths)
|
||||
&& this.separateSyntaxServer === other.separateSyntaxServer
|
||||
@@ -153,6 +161,14 @@ export class TypeScriptServiceConfiguration {
|
||||
return configuration.get<boolean>('javascript.implicitProjectConfig.experimentalDecorators', false);
|
||||
}
|
||||
|
||||
private static readImplicitStrictNullChecks(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('js/ts.implicitProjectConfig.strictNullChecks', true);
|
||||
}
|
||||
|
||||
private static readImplicitStrictFunctionTypes(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('js/ts.implicitProjectConfig.strictFunctionTypes', true);
|
||||
}
|
||||
|
||||
private static readNpmLocation(configuration: vscode.WorkspaceConfiguration): string | null {
|
||||
return configuration.get<string | null>('typescript.npm', null);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,14 @@ export function inferredProjectCompilerOptions(
|
||||
projectConfig.experimentalDecorators = true;
|
||||
}
|
||||
|
||||
if (serviceConfig.implicitStrictNullChecks) {
|
||||
projectConfig.strictNullChecks = true;
|
||||
}
|
||||
|
||||
if (serviceConfig.implicitStrictFunctionTypes) {
|
||||
projectConfig.strictFunctionTypes = true;
|
||||
}
|
||||
|
||||
if (projectType === ProjectType.TypeScript) {
|
||||
projectConfig.sourceMap = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user