Skip to content

Commit 9496c5c

Browse files
committed
Fixed tsconfig.ts to use the projectSpec
1 parent d354d37 commit 9496c5c

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

dist/main/tsconfig/tsconfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function getProjectSync(pathOrSrcFile) {
253253
externalTranspiler: projectSpec.externalTranspiler == undefined ? undefined : projectSpec.externalTranspiler,
254254
scripts: projectSpec.scripts || {},
255255
buildOnSave: !!projectSpec.buildOnSave,
256-
atom: { rewriteTsconfig: true, formatOnSave: false }
256+
atom: { rewriteTsconfig: true, formatOnSave: !!projectSpec.atom.formatOnSave }
257257
};
258258
var validationResult = validator.validate(projectSpec.compilerOptions);
259259
if (validationResult.errorMessage) {

lib/main/atom/onSaveHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function handle(event: { filePath: string; editor: AtomCore.IEditor }) {
5454
}
5555

5656
if (fileDetails.project.atom.formatOnSave) {
57+
// Trigger a format
5758
atom.commands.dispatch(
5859
atom.views.getView(event.editor),
5960
'typescript:format-code');

lib/main/tsconfig/tsconfig.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function mixin(target: any, source: any): any {
290290

291291
function rawToTsCompilerOptions(jsonOptions: CompilerOptions, projectDir: string): ts.CompilerOptions {
292292
// Cannot use Object.create because the compiler checks hasOwnProperty
293-
var compilerOptions = <ts.CompilerOptions> mixin({}, defaults);
293+
var compilerOptions = <ts.CompilerOptions>mixin({}, defaults);
294294
for (var key in jsonOptions) {
295295
if (typescriptEnumMap[key]) {
296296
compilerOptions[key] = typescriptEnumMap[key][jsonOptions[key].toLowerCase()];
@@ -322,7 +322,7 @@ function rawToTsCompilerOptions(jsonOptions: CompilerOptions, projectDir: string
322322

323323
function tsToRawCompilerOptions(compilerOptions: ts.CompilerOptions): CompilerOptions {
324324
// Cannot use Object.create because JSON.stringify will only serialize own properties
325-
var jsonOptions = <CompilerOptions> mixin({}, compilerOptions);
325+
var jsonOptions = <CompilerOptions>mixin({}, compilerOptions);
326326

327327
Object.keys(compilerOptions).forEach((key) => {
328328
if (jsonEnumMap[key] && compilerOptions[key]) {
@@ -375,8 +375,8 @@ export function getProjectSync(pathOrSrcFile: string): TypeScriptProjectFileDeta
375375
var projectFile = tsconfig.resolveSync(dir);
376376

377377
if (!projectFile) {
378-
throw errorWithDetails<GET_PROJECT_NO_PROJECT_FOUND_Details>(
379-
new Error(errors.GET_PROJECT_NO_PROJECT_FOUND), { projectFilePath: fsu.consistentPath(pathOrSrcFile), errorMessage: 'not found' });
378+
throw errorWithDetails<GET_PROJECT_NO_PROJECT_FOUND_Details>(
379+
new Error(errors.GET_PROJECT_NO_PROJECT_FOUND), { projectFilePath: fsu.consistentPath(pathOrSrcFile), errorMessage: 'not found' });
380380
}
381381

382382
var projectFileDirectory = path.dirname(projectFile) + path.sep;
@@ -442,7 +442,7 @@ export function getProjectSync(pathOrSrcFile: string): TypeScriptProjectFileDeta
442442
externalTranspiler: projectSpec.externalTranspiler == undefined ? undefined : projectSpec.externalTranspiler,
443443
scripts: projectSpec.scripts || {},
444444
buildOnSave: !!projectSpec.buildOnSave,
445-
atom: { rewriteTsconfig: true, formatOnSave: false }
445+
atom: { rewriteTsconfig: true, formatOnSave: !!projectSpec.atom.formatOnSave }
446446
};
447447

448448
// Validate the raw compiler options before converting them to TS compiler options
@@ -521,7 +521,7 @@ function increaseProjectForReferenceAndImports(files: string[]): string[] {
521521
}
522522
}
523523

524-
var getReferencedOrImportedFiles = (files: string[]): string[]=> {
524+
var getReferencedOrImportedFiles = (files: string[]): string[] => {
525525
var referenced: string[][] = [];
526526

527527
files.forEach(file => {
@@ -553,7 +553,7 @@ function increaseProjectForReferenceAndImports(files: string[]): string[] {
553553
return file;
554554
}
555555
return getIfExists(file);
556-
}).filter(file=> !!file)
556+
}).filter(file => !!file)
557557
.concat(
558558
preProcessedFileInfo.importedFiles
559559
.filter((fileReference) => pathIsRelative(fileReference.fileName))
@@ -564,7 +564,7 @@ function increaseProjectForReferenceAndImports(files: string[]): string[] {
564564
file = getIfExists(`${file}/index`);
565565
}
566566
return file;
567-
}).filter(file=> !!file)
567+
}).filter(file => !!file)
568568
)
569569
);
570570
});
@@ -610,9 +610,9 @@ function getDefinitionsForNodeModules(projectDir: string, files: string[]): { ou
610610
// Find our `typings` (anything in a typings folder with extension `.d.ts` is considered a typing)
611611
// These are INF powerful
612612
var ourTypings = files
613-
.filter(f=> path.basename(path.dirname(f)) == 'typings' && endsWith(f, '.d.ts')
613+
.filter(f => path.basename(path.dirname(f)) == 'typings' && endsWith(f, '.d.ts')
614614
|| path.basename(path.dirname(path.dirname(f))) == 'typings' && endsWith(f, '.d.ts'));
615-
ourTypings.forEach(f=> typings[path.basename(f)] = { filePath: f, version: Infinity });
615+
ourTypings.forEach(f => typings[path.basename(f)] = { filePath: f, version: Infinity });
616616
var existing = createMap(files.map(fsu.consistentPath));
617617

618618
function addAllReferencedFilesWithMaxVersion(file: string) {
@@ -635,7 +635,7 @@ function getDefinitionsForNodeModules(projectDir: string, files: string[]): { ou
635635
if (fs.existsSync(file + '.d.ts')) {
636636
return file + '.d.ts';
637637
}
638-
}).filter(f=> !!f);
638+
}).filter(f => !!f);
639639

640640
// Only ones we don't have by name yet
641641
// TODO: replace INF with an actual version
@@ -644,7 +644,7 @@ function getDefinitionsForNodeModules(projectDir: string, files: string[]): { ou
644644
// Add these
645645
files.forEach(f => typings[path.basename(f)] = { filePath: f, version: Infinity });
646646
// Keep expanding
647-
files.forEach(f=> addAllReferencedFilesWithMaxVersion(f));
647+
files.forEach(f => addAllReferencedFilesWithMaxVersion(f));
648648
}
649649

650650
// Keep going up till we find node_modules
@@ -691,11 +691,11 @@ function getDefinitionsForNodeModules(projectDir: string, files: string[]): { ou
691691

692692
var all = Object.keys(typings)
693693
.map(typing => typings[typing].filePath)
694-
.map(x=> fsu.consistentPath(x));
694+
.map(x => fsu.consistentPath(x));
695695
var implicit = all
696-
.filter(x=> !existing[x]);
696+
.filter(x => !existing[x]);
697697
var ours = all
698-
.filter(x=> existing[x]);
698+
.filter(x => existing[x]);
699699

700700
return { implicit, ours, packagejson };
701701
}

lib/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
],
135135
"exclude": [],
136136
"atom": {
137-
"rewriteTsconfig": true
137+
"rewriteTsconfig": true,
138+
"formatOnSave": false
138139
}
139140
}

0 commit comments

Comments
 (0)