File tree 5 files changed +38
-17
lines changed
5 files changed +38
-17
lines changed Original file line number Diff line number Diff line change 14
14
},
15
15
"license" : " MIT" ,
16
16
"files" : [
17
- " index.js"
17
+ " index.js" ,
18
+ " types/index.d.ts"
18
19
],
19
20
"main" : " index.js" ,
20
- "types" : " split-string .d.ts" ,
21
+ "types" : " types/index .d.ts" ,
21
22
"engines" : {
22
23
"node" : " >=8.6"
23
24
},
24
25
"scripts" : {
25
- "test" : " nyc mocha"
26
+ "test" : " nyc mocha" ,
27
+ "test:types" : " dtslint types"
26
28
},
27
29
"devDependencies" : {
30
+ "dtslint" : " ^0.7.0" ,
28
31
"gulp-format-md" : " ^1.0.0" ,
29
32
"mocha" : " ^5.2.0" ,
30
33
"nyc" : " ^12.0.2"
Original file line number Diff line number Diff line change 1
- interface ASTNode {
1
+ // TypeScript Version: 3.0
2
+
3
+ export interface ASTNode {
2
4
type : 'root' | 'bracket' ;
3
5
nodes : ASTNode [ ] ;
4
6
stash : string [ ] ;
5
7
}
6
8
7
- interface State {
9
+ export interface State {
8
10
input : string ;
9
11
separator : string ;
10
12
stack : ASTNode [ ] ;
@@ -14,7 +16,7 @@ interface State {
14
16
next ( ) : string ;
15
17
}
16
18
17
- interface Options {
19
+ export interface Options {
18
20
brackets ?: { [ key : string ] : string } | boolean ;
19
21
quotes ?: string [ ] | boolean ;
20
22
separator ?: string ;
@@ -24,9 +26,7 @@ interface Options {
24
26
25
27
type SplitFunc = ( state : State ) => boolean ;
26
28
27
- declare function split ( input : string ) : string [ ] ;
28
- declare function split ( input : string , options : Options ) : string [ ] ;
29
- declare function split ( input : string , fn : SplitFunc ) : string [ ] ;
29
+ declare function split ( input : string , options ?: Options | SplitFunc ) : string [ ] ;
30
30
declare function split ( input : string , options : Options , fn : SplitFunc ) : string [ ] ;
31
31
32
32
export default split ;
Original file line number Diff line number Diff line change 1
1
/**
2
2
* Testing the TypeScript definitions for split-string.
3
3
*/
4
- import split from '../ ' ;
4
+ import split , { State } from '.' ;
5
5
6
- function keep ( value , state ) {
6
+ function keep ( value : string , state : State ) {
7
7
return value !== '\\' && ( value !== '"' || state . prev ( ) === '\\' ) ;
8
- } ;
8
+ }
9
9
10
- function splitFunc ( state ) {
10
+ function splitFunc ( state : State ) {
11
11
console . log ( state ) ;
12
12
return state . prev ( ) === 'a' ;
13
13
}
@@ -27,7 +27,8 @@ split('«a.b».⟨c.d⟩.[e.f]', {
27
27
split ( 'a.b.c.a.d.e' , splitFunc ) ;
28
28
split ( 'a.b."c.d.e.f.g".h.i' , { quotes : [ '"' ] } , splitFunc ) ;
29
29
30
- // should error
31
- split ( ) ;
32
- split ( splitFunc ) ;
33
- split ( { quotes : [ '"' ] } ) ;
30
+ // Make sure invalid calls fail
31
+
32
+ split ( ) ; // $ExpectError
33
+ split ( splitFunc ) ; // $ExpectError
34
+ split ( { quotes : [ '"' ] } ) ; // $ExpectError
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "module" : " commonjs" ,
4
+ "lib" : [" es6" , " dom" ],
5
+ "noImplicitAny" : true ,
6
+ "noImplicitThis" : true ,
7
+ "strictNullChecks" : true ,
8
+ "strictFunctionTypes" : true ,
9
+ "noEmit" : true
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "extends" : " dtslint/dtslint.json" ,
3
+ "rules" : {
4
+ "no-relative-import-in-test" : false
5
+ }
6
+ }
You can’t perform that action at this time.
0 commit comments