Skip to content

Commit

Permalink
Set sourceMap: true in default tsconfig
Browse files Browse the repository at this point in the history
For #87972
  • Loading branch information
mjbvz committed Jan 6, 2020
1 parent 81fb34c commit f105af6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { TypeScriptPluginPathsProvider } from './utils/pluginPathsProvider';
import { PluginManager } from './utils/plugins';
import TelemetryReporter, { VSCodeTelemetryReporter } from './utils/telemetry';
import Tracer from './utils/tracer';
import { inferredProjectConfig } from './utils/tsconfig';
import { inferredProjectCompilerOptions } from './utils/tsconfig';
import { TypeScriptVersionPicker } from './utils/versionPicker';
import { TypeScriptVersion, TypeScriptVersionProvider } from './utils/versionProvider';

Expand Down Expand Up @@ -498,7 +498,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType

private getCompilerOptionsForInferredProjects(configuration: TypeScriptServiceConfiguration): Proto.ExternalProjectCompilerOptions {
return {
...inferredProjectConfig(configuration),
...inferredProjectCompilerOptions(true, configuration),
allowJs: true,
allowSyntheticDefaultImports: true,
allowNonTsExtensions: true,
Expand Down
14 changes: 10 additions & 4 deletions extensions/typescript-language-features/src/utils/tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export function isImplicitProjectConfigFile(configFileName: string) {
return configFileName.startsWith('/dev/null/');
}

export function inferredProjectConfig(
export function inferredProjectCompilerOptions(
isTypeScriptProject: boolean,
serviceConfig: TypeScriptServiceConfiguration,
): Proto.ExternalProjectCompilerOptions {
const projectConfig: Proto.ExternalProjectCompilerOptions = {
Expand All @@ -29,13 +30,18 @@ export function inferredProjectConfig(
projectConfig.experimentalDecorators = true;
}

if (isTypeScriptProject) {
projectConfig.sourceMap = true;
}

return projectConfig;
}

function inferredProjectConfigSnippet(
isTypeScriptProject: boolean,
config: TypeScriptServiceConfiguration
) {
const baseConfig = inferredProjectConfig(config);
const baseConfig = inferredProjectCompilerOptions(isTypeScriptProject, config);
const compilerOptions = Object.keys(baseConfig).map(key => `"${key}": ${JSON.stringify(baseConfig[key])}`);
return new vscode.SnippetString(`{
"compilerOptions": {
Expand All @@ -62,8 +68,8 @@ export async function openOrCreateConfigFile(
const doc = await vscode.workspace.openTextDocument(configFile.with({ scheme: 'untitled' }));
const editor = await vscode.window.showTextDocument(doc, col);
if (editor.document.getText().length === 0) {
await editor.insertSnippet(inferredProjectConfigSnippet(config));
await editor.insertSnippet(inferredProjectConfigSnippet(isTypeScriptProject, config));
}
return editor;
}
}
}

0 comments on commit f105af6

Please sign in to comment.