New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use TypeScript #9
Comments
Sure. I would like to see #4 merged first though. |
This can be implemented now. |
@sindresorhus
If we mean to expose a manual declare module "@sindresorhus/is" {
export interface Is {
(val: any): string;
undefined: TypeQueryMethod;
null: TypeQueryMethod;
string: TypeQueryMethod;
number: TypeQueryMethod;
boolean: TypeQueryMethod;
symbol: TypeQueryMethod;
array: TypeQueryMethod;
function: TypeQueryMethod;
buffer: TypeQueryMethod;
object: TypeQueryMethod;
nativePromise: TypeQueryMethod;
promise: TypeQueryMethod;
regExp: TypeQueryMethod;
date: TypeQueryMethod;
error: TypeQueryMethod;
map: TypeQueryMethod;
set: TypeQueryMethod;
weakMap: TypeQueryMethod;
weakSet: TypeQueryMethod;
int8Array: TypeQueryMethod;
uint8Array: TypeQueryMethod;
uint8ClampedArray: TypeQueryMethod;
int16Array: TypeQueryMethod;
uint16Array: TypeQueryMethod;
int32Array: TypeQueryMethod;
uint32Array: TypeQueryMethod;
float32Array: TypeQueryMethod;
float64Array: TypeQueryMethod;
arrayBuffer: TypeQueryMethod;
sharedArrayBuffer: TypeQueryMethod;
nan: TypeQueryMethod;
nullOrUndefined: TypeQueryMethod;
primitive: TypeQueryMethod;
integer: TypeQueryMethod;
plainObject: TypeQueryMethod;
iterable: TypeQueryMethod;
class: TypeQueryMethod;
typedArray: TypeQueryMethod;
inRange: {
(value: number, range: number): boolean;
(value: number, [first, last]: Array<number>): boolean;
}
}
const is: Is;
} not exactly sure on how do I test it, but I'm sure there's an easy way. Gonna keep figuring it out. If we doing the |
@sindresorhus if we re-write in |
Just chiming in here: I don't really see the need to rewrite this in TS. TS works well with large codebases and I don't see the need to bring in the concept of static-typing in here. TS can act as a replacement for Babel, but once again, in this case, I don't see the need to. A simple build script that transpiles ES6+ code should suffice. Again, this is just my input on this matter. What are you guys' thoughts on this @gioragutt @sindresorhus? |
We can just make a TS file with various use-cases and run TS on it.
Yeah, I think TS type definitions would be good enough for our needs.
I don't really see the point of that. |
I guess it's decided. I'm not at all familiar with TS, so if you see the benefit, then there's nothing more for me to add here. 🚶
^ transpiling would help in this case, wouldn't it? Just wondering 🤔 |
Not worth adding a build-step just for a tiny syntactic feature. |
@gioragutt Thoughts? Could you do a PR with your above type definition? |
@sindresorhus I will when I'll have some free time for it, currently rather busy. I do have to notice #8, I'm currently using CRA, and I'd have loved to have it, but as you can see, the issue submitter says that CRA can't deal with it. I'd say this is slightly higher priority than TS support. |
@sindresorhus I do have to say now, I've tried installing |
@sindresorhus we could really use some ES5 features, I do believe that it's worth adding a step (which can be automatically done via npm scripts) to allow us to write much cleaner code, while keeping the compatibility that we want. Consider that. Take f.e #19 , he ends up having to use The more we delay this, the more we have to write less readable and maintainable code, and to keep it Well maintained, it has to be as maintainable as we can bring it to be. I know you have dozens of small, 10 liner libraries, but this isn't one. |
Having to use older syntax creates overhead, true, but so does a build step. I wouldn't add a build step personally, but I'm ok with doing it here if someone else does the work. But if we're going to add a build step, it would make more sense to do the module in TypeScript. That way we don't have to manually keep the type definition file up to date. |
Fixed by #28 |
I think that re-writing the code in
typescript
could really help this library, for the following reasons -typescript
based codebasesJS
/TS
features, while keeping compatibility with olderNode
versionsThink about the
inRange
pull-request - we could not usearray destructuring
because this messed up compatibility withNode v4
.If we write this in
typescript
, the compiledjs
will be compatible with older versions, while the source code will be written with everyJS
feature we see fit.The text was updated successfully, but these errors were encountered: