Skip to content

Commit 294c7c9

Browse files
authored
Merge pull request #138 from hildjj/AddAnyToValues
Allow any value for any property
2 parents 7b55b78 + 0ec69a9 commit 294c7c9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/index.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,26 @@ const matchOptions = {matchBase: true, dot: true};
1313

1414
// These are specified by the editorconfig script
1515
export interface KnownProps {
16+
charset?: 'latin1' | 'utf-8' | 'utf-8-bom' | 'utf-16be' | 'utf-16le' | 'unset';
1617
end_of_line?: 'lf' | 'crlf' | 'unset';
17-
indent_style?: 'tab' | 'space' | 'unset';
1818
indent_size?: number | 'tab' | 'unset';
19+
indent_style?: 'tab' | 'space' | 'unset';
1920
insert_final_newline?: true | false | 'unset';
2021
tab_width?: number | 'unset';
2122
trim_trailing_whitespace?: true | false | 'unset';
22-
charset?: 'latin1' | 'utf-8' | 'utf-8-bom' | 'utf-16be' | 'utf-16le' | 'unset';
2323
}
2424

25-
interface UnknownMap {
25+
export interface UnknownMap {
2626
[index: string]: unknown;
2727
}
28-
export type Props = KnownProps & UnknownMap;
28+
29+
export type PossibleValue = boolean | number | (string & {});
30+
31+
export type AddPossibleValues<T extends object> = {
32+
[K in keyof T]: T[K] | PossibleValue;
33+
};
34+
35+
export type Props = AddPossibleValues<KnownProps> & UnknownMap;
2936

3037
export interface ECFile {
3138
name: string;
@@ -62,12 +69,13 @@ export interface ParseOptions {
6269
}
6370

6471
const knownPropNames: (keyof KnownProps)[] = [
72+
'charset',
6573
'end_of_line',
66-
'indent_style',
6774
'indent_size',
75+
'indent_style',
6876
'insert_final_newline',
77+
// 'tab_width' // This should be an integer, not a string.
6978
'trim_trailing_whitespace',
70-
'charset',
7179
];
7280
const knownProps = new Set<string>(knownPropNames);
7381

0 commit comments

Comments
 (0)