Comments (6)
@valepu
https://www.npmjs.com/package/is
andhttps://www.npmjs.com/package/is_js
are two entirely different libraries.
@shivam-tripathi Yes, but the types are for is_js despite being called @types/is.
I can confirm this because the function is.existy is available in "is_js" but not in "is". On top of that if you check the file https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/is/index.d.ts you can read the following
// Type definitions for is.js
// Project: http://arasatasaygin.github.io/is.js/
// Definitions by: Rodrigo Cabral <https://github.com/cabralRodrigo>, Mitchell Grice <https://github.com/gricey432>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
from is.js.
There is a bit of a problem with the @types
.
The DefinitelyTyped package for is_js
seems to be @types/is
(i have tried @types/is_js @types/is-js @types/is.js @types/isjs but they don't exist), and the method calls seem correct, but if i import it like this:
import * as is from 'is_js';
i get an error saying it can't find the type definition when building (despite VS code not giving me any error). if i import it like this
import * as is from 'is';
I get a different error. The solution seems to be to install is_js with an alias: "is": "npm:is_js@^0.9.0",
and then import the module like this import * as is from 'is';
if i do like this it seems to work but maybe i'm doing something completely wrong
from is.js.
To illustrate that @valepu is correct and there is a mismatch here:
- navigate to https://www.npmjs.com/package/@types/is
- Read :
This package contains type definitions for is.js (http://arasatasaygin.github.io/is.js/).
- navigate to http://arasatasaygin.github.io/is.js
- click "View On Github", navigates to https://github.com/arasatasaygin/is.js
- Notice that the package name used in the readme directions is
is_js
from is.js.
Update: I discovered that @types/is
exports their types for both modules is
and is_js
.
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/is/index.d.ts#L1377-L1383
That can't be right.
from is.js.
@valepu https://www.npmjs.com/package/is
and https://www.npmjs.com/package/is_js
are two entirely different libraries.
from is.js.
Well I buckled and switched from is_js
to is
purely for easy typescript support, though I preferred the is_js
api.
Also type definitions in @types/is
aren't typeguard-friendly. I believe should be (x:unknown) : x is string
and not (x:unknown) : boolean
. Might log issue in that repo.
from is.js.
Related Issues (20)
- Feature: Support for identify IOS 13 HOT 1
- logical && and logical || HOT 2
- is.chrome() environment check invalid for Chrome 77 - macOS (Mojave)
- is.tablet() returns false on iPad HOT 4
- is.number returns True for `Infinity` and `-Infinity` HOT 2
- documentation for `is.palindrome` should explain limitation HOT 1
- This lib do nots work in Vue.js HOT 2
- is.empty(undefined) returns false
- is.edge() returns false in edge (tested on windows and mac os) HOT 3
- is.chrome() returns true in edge HOT 2
- Getting error when checking if window is defined HOT 4
- How to import this into webpack or laravel-mix?
- Security Issue: Request for contact HOT 5
- is.safari() return true in MS Edge browser HOT 2
- is.chrome() return true in MS Edge browser and is.not.edge() return true in MS edge as well.
- Trying to get in touch regarding a security issue HOT 8
- Contributing new features? HOT 2
- Vulnerability
- npm.js 官网上 发布的版本是 0.9.0,代码上的版本是 0.8.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from is.js.