Commit 2d1bd3f 1 parent 854bab6 commit 2d1bd3f Copy full SHA for 2d1bd3f
File tree 3 files changed +23
-3
lines changed
3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,16 @@ export interface FrontMatterResult<T> {
5
5
readonly frontmatter ?: string
6
6
}
7
7
8
+ export interface FrontMatterOptions {
9
+ /**
10
+ * Whether to use [safeload](https://github.com/nodeca/js-yaml#safeload-string---options-)
11
+ * @default true
12
+ */
13
+ allowUnsafe ?: boolean
14
+ }
15
+
8
16
interface FM {
9
- < T > ( file : string ) : FrontMatterResult < T >
17
+ < T > ( file : string , options ?: FrontMatterOptions ) : FrontMatterResult < T >
10
18
test ( file : string ) : boolean
11
19
}
12
20
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ let nullBox: null;
19
19
/* ===================== fm ===================== */
20
20
21
21
{
22
- // THROWS 1 arguments, but got 0.
22
+ // THROWS Expected 1-2 arguments, but got 0.
23
23
fm ( )
24
24
}
25
25
@@ -28,6 +28,11 @@ let nullBox: null;
28
28
fm ( null )
29
29
}
30
30
31
+ {
32
+ // THROWS 'string' is not assignable to type 'boolean | undefined'.
33
+ fm ( file , { allowUnsafe : 'yes' } )
34
+ }
35
+
31
36
{
32
37
33
38
// THROWS 'FrontMatterResult<unknown>' is not assignable to type 'null'.
@@ -69,7 +74,6 @@ let nullBox: null;
69
74
}
70
75
71
76
{
72
-
73
77
// THROWS Type 'boolean' is not assignable to type 'null'.
74
78
nullBox = fm . test ( file )
75
79
}
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ This is some text about some stuff that happened sometime ago`;
28
28
console . log ( bodyBegin ) ;
29
29
console . log ( frontmatter ) ;
30
30
}
31
+
32
+ {
33
+ fm ( file )
34
+ }
35
+
36
+ {
37
+ fm ( file , { allowUnsafe : true } )
38
+ }
31
39
}
32
40
33
41
{
You can’t perform that action at this time.
0 commit comments