Skip to content

Commit 687528a

Browse files
committed
Make userpreferences configurable via tsconfig "preferences"
1 parent fc5729e commit 687528a

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

lib/main/atom/utils/ts.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
SignatureHelpItem,
1010
SignatureHelpParameter,
1111
TextSpan,
12+
UserPreferences,
1213
} from "typescript/lib/protocol"
1314

1415
// NOTE: using TypeScript internals here. May be brittle!
@@ -56,12 +57,13 @@ export function rangeToLocationRange(range: Atom.Range): LocationRangeQuery {
5657
}
5758
}
5859

59-
export function getProjectConfig(
60-
configFile: string,
61-
): {
60+
export interface ProjectConfig {
6261
formatCodeOptions: FormatCodeSettings
6362
compileOnSave: boolean
64-
} {
63+
preferences: UserPreferences
64+
}
65+
66+
export function getProjectConfig(configFile: string): ProjectConfig {
6567
const config = loadConfig(configFile)
6668
const options = (config as {formatCodeOptions?: FormatCodeSettings}).formatCodeOptions
6769

@@ -72,15 +74,11 @@ export function getProjectConfig(
7274
...options,
7375
},
7476
compileOnSave: !!config.compileOnSave,
77+
preferences: config.preferences ? config.preferences : {},
7578
}
7679
}
7780

78-
function loadConfig(
79-
configFile: string,
80-
): {
81-
formatCodeOptions?: FormatCodeSettings
82-
compileOnSave?: boolean
83-
} {
81+
function loadConfig(configFile: string): Partial<ProjectConfig> {
8482
if (path.extname(configFile) !== ".json") {
8583
configFile = `${configFile}.json`
8684
}

lib/main/typescriptBuffer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export class TypescriptBuffer {
173173
"atom-typescript.includeCompletionsForModuleExports",
174174
),
175175
quotePreference: atom.config.get("atom-typescript.quotePreference"),
176+
...options.preferences,
176177
},
177178
})
178179
}

0 commit comments

Comments
 (0)