File tree 5 files changed +26
-1
lines changed
5 files changed +26
-1
lines changed Original file line number Diff line number Diff line change
1
+ declare function isString ( value : unknown ) : value is string | String ;
2
+
3
+ export = isString ;
Original file line number Diff line number Diff line change 2
2
3
3
var callBound = require ( 'call-bind/callBound' ) ;
4
4
5
+ /** @type {(receiver: ThisParameterType<typeof String.prototype.valueOf>, ...args: Parameters<typeof String.prototype.valueOf>) => ReturnType<typeof String.prototype.valueOf> } */
5
6
var $strValueOf = callBound ( 'String.prototype.valueOf' ) ;
6
7
8
+ /** @type {import('.') } */
7
9
var tryStringObject = function tryStringObject ( value ) {
8
10
try {
9
11
$strValueOf ( value ) ;
@@ -12,10 +14,12 @@ var tryStringObject = function tryStringObject(value) {
12
14
return false ;
13
15
}
14
16
} ;
17
+ /** @type {(receiver: ThisParameterType<typeof Object.prototype.toString>, ...args: Parameters<typeof Object.prototype.toString>) => ReturnType<typeof Object.prototype.toString> } */
15
18
var $toString = callBound ( 'Object.prototype.toString' ) ;
16
19
var strClass = '[object String]' ;
17
20
var hasToStringTag = require ( 'has-tostringtag/shams' ) ( ) ;
18
21
22
+ /** @type {import('.') } */
19
23
module . exports = function isString ( value ) {
20
24
if ( typeof value === 'string' ) {
21
25
return true ;
Original file line number Diff line number Diff line change 19
19
"posttest" : " npx npm@'>=10.2' audit --production" ,
20
20
"prelint" : " eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\ .git')" ,
21
21
"lint" : " eslint --ext=js,mjs ." ,
22
+ "postlint" : " tsc -p . && attw -P" ,
22
23
"version" : " auto-changelog && git add CHANGELOG.md" ,
23
24
"postversion" : " auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \" v$(node -e \" console.log(require('./package.json').version)\" )\" "
24
25
},
39
40
"has-tostringtag" : " ^1.0.2"
40
41
},
41
42
"devDependencies" : {
43
+ "@arethetypeswrong/cli" : " ^0.17.0" ,
42
44
"@ljharb/eslint-config" : " ^21.1.1" ,
45
+ "@ljharb/tsconfig" : " ^0.2.0" ,
46
+ "@types/call-bind" : " ^1.0.5" ,
47
+ "@types/core-js" : " ^2.5.8" ,
48
+ "@types/tape" : " ^5.6.5" ,
43
49
"auto-changelog" : " ^2.5.0" ,
44
50
"core-js" : " ^3.39.0" ,
45
51
"eclint" : " ^2.8.1" ,
50
56
"npmignore" : " ^0.3.1" ,
51
57
"nyc" : " ^10.3.2" ,
52
58
"safe-publish-latest" : " ^2.0.0" ,
53
- "tape" : " ^5.9.0"
59
+ "tape" : " ^5.9.0" ,
60
+ "typescript" : " next"
54
61
},
55
62
"testling" : {
56
63
"files" : " test/index.js" ,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ var isString = require('../');
5
5
var hasToStringTag = require ( 'has-tostringtag/shams' ) ( ) ;
6
6
7
7
test ( 'not Strings' , function ( t ) {
8
+ // @ts -expect-error
8
9
t . notOk ( isString ( ) , 'undefined is not String' ) ;
9
10
t . notOk ( isString ( null ) , 'null is not String' ) ;
10
11
t . notOk ( isString ( false ) , 'false is not String' ) ;
@@ -23,6 +24,7 @@ test('not Strings', function (t) {
23
24
} ) ;
24
25
25
26
test ( '@@toStringTag' , { skip : ! hasToStringTag } , function ( t ) {
27
+ /** @type {{ toString(): unknown; valueOf(): unknown; [Symbol.toStringTag]?: string; } } */
26
28
var fakeString = {
27
29
toString : function ( ) { return '7' ; } ,
28
30
valueOf : function ( ) { return '42' ; }
Original file line number Diff line number Diff line change
1
+ {
2
+ "extends": "@ljharb/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ES2021",
5
+ },
6
+ "exclude": [
7
+ "coverage"
8
+ ]
9
+ }
You can’t perform that action at this time.
0 commit comments