Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Conversation

@kevinoid
Copy link
Collaborator

As a follow-up to the last pull request, I've gone ahead and fixed the type errors in the non-contrib modules.

I think this resolves most of the issues, although there are a few things that I didn't touch that you may want to take a look at:

  • I wasn't sure what the purpose of ReadableStream and WritableStream were. I couldn't find any references in the node documentation. So I mostly left them alone.
  • stream.Duplex currently doesn't inherit from stream.Writable. This needs to be fixed, but due to Issue 250 and lack of support for mixins, this won't be easy.
  • Some of the changes to the stream module may break code using really old versions of node. This namespace has changed a lot and I'm not very familiar with the old interfaces. Although it looks safe, I'm sure there are some corner cases.
  • I'm not sure why many of the module namespaces are annotated as dictionary objects. So I left them as-is.

Cheers,
Kevin

kevinoid added 17 commits April 13, 2013 08:58
Array and Object were often written as array and object, causing
warnings such as:

./buffer.js:32: WARNING - Bad type annotation. Unknown type object
 * @type {object.<string,*>}
          ^

Fix the warnings by correcting the capitalization.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
The intent of these annotations seems clear, fix the typos.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
The type requires the buffer namespace in order to be resolved.  Add it
where missing.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
From source inspection and usage, it's clear that Buffer doesn't extend
Array (for example, Buffer has no pop method).  Remove this annotation
(which also fixes the type incompatibility of the slice method).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
cluster is actually an instance of the private Cluster type, which
extends EventEmitter.  Therefore, annotate cluster as being of type
EventEmitter.

Note:  This code is now not runnable, since assigning to cluster would
require either reference to the events namespace (which isn't imported)
or leaving it null which would fail for subsequent property accesses.
But that's fine, since externs aren't run.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
According to the docs (and code) this argument is optional.  This also
fixes the warning about non-optional arguments following optional
arguments.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Although it has the same type as the global require function, the global
require function isn't a type (constructor).  So update the type of
module.require to match it.  This fixes the following warning:

./core.js:76: WARNING - Bad type annotation. Unknown type require
 * @type {require}
          ^

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Update the annotations to match their definitions in node 0.10.  Also,
stream (the namespace) is not a class, use stream.Stream instead as
appropriate.

This commit doesn't fix the multiple inheritance/mixin issue with Duplex
needing to extend from both Readable and Writable.  This may require
defining some interfaces which can be implemented.

This commit also doesn't touch ReadableStream and WritableStream.  I'm
not sure of the purpose of these classes and since they are heavily used
in other namespaces, I'll leave them alone for now.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
All of the functions which take a time argument accept either numbers
(as seconds since the epoch) or a Date.  Add the Date type to arguments
where it was missing.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
The properties of Stat with Date type were being assigned numbers, which
caused compile warnings.  Remove the unnecessary assignment.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Replace the http.ServerRequest and http.ClientResponse classes with the
IncomingMessage class, as is done in recent versions of node.  Add the
missing members to the prototype.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Lots of refactoring to work around the fact that Closure Compiler
doesn't have proper support for mixins.  Ensure that @extends meets the
requirement that X instanceof Y if X @extends Y.  Add copies of the
annotations for all mixin methods and aliased functions.

Also add missing annotations for pbkdf2.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
These members are all inherited from net.Server and don't need to be
redefined for tls.Server (and the listen definition was causing type
warnings).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
I'm not sure if this used to be added by node, but I can't find it
anywhere in the docs or code in recent versions.  It was also causing
the following warning (due to a conflict with util.inspect):

./util.js:77: WARNING - assignment to property inspect of Object.<string,*>
found   : function (*, boolean=, number=, boolean=): string
required: function (this:Object): ?
util.inspect = function(object, showHidden, depth, colors) {};
^

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Until we decide what to do with WritableStream, fix it to avoid
producing any warnings.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
The side-effect of this method is copying data into the target buffer
given as an argument.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
The side-effectfulness of these functions is determined based on whether
the callback function has side-effects.  Presumably it does (what's the
point of the callback otherwise?).  So remove the @nosideeffects
annotation.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
@dcodeIO
Copy link
Owner

dcodeIO commented Apr 13, 2013

Looks like you are better in writing externs than I am, so I added you as a collaborator :). You should now be able to commit / merge changes directly.

@kevinoid
Copy link
Collaborator Author

Hah. Guess that's an indication I've spent too much time trying to figure this thing out. ;)

Thanks!

kevinoid added a commit that referenced this pull request Apr 13, 2013
@kevinoid kevinoid merged commit 89d61c5 into dcodeIO:master Apr 13, 2013
@kevinoid kevinoid deleted the fix-some-type-errors branch April 13, 2013 20:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants