-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fix: Update typings for q1 2022 release #6051
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the explanations of each of your steps, and for the gist (to you and Aaron). Hopefully this is the last quarter have to do this.
Fixed the |
The basics
npm run format
andnpm run lint
The details
Proposed Changes
To generate this code, I started with Aaron's esmodules branch, which contains an esmodule-ified version of Blockly. Then, I changed the tsconfig in the file to have it output declaration files:
Then run
npx tsc
and fix errors until it worked. To resolve various errors (mostly cryptic messages like "Declaration emit for this file requires using private name 'IPathObject'. An explicit type annotation may unblock declaration emit.") I did the following (to the best of my memory, may have left out some changes):i_path_object.js
constructor to not take any parameters. This made the aforementioned cryptic error disappear.goog.require
statements toimport
but not thegoog.requireType
statements. Aaron had previously made a script that converted these statements, which he kindly provided and then I modified to work forrequireType
. Aaron wrote this but I put it in this gist for longevity. This got rid of a bunch of errors about not being able to resolve the type, and got rid of a bunch of "any" types.Metrics
inWorkspaceSvg
even thoughMetrics
worked fine in other places likeMetricsManager
. The error persisted even if I removed the only mention ofMetrics
fromWorkspaceSvg
. Thanks again to Aaron, we resolved this by convertingutils/metrics.js
to a class.At this point is approximately where I committed the changes so far to the "initial commit" because the
tsc
command succeeded with no errors, despite the output file still having problems. Additional changes made in separate commits:MyClass implements SomeInterface
appears we get an error like'IASTNodeLocation' refers to a value, but is being used as a type here. Did you mean 'typeof IASTNodeLocation'?
however its suggested solution of addingtypeof
doesn't work. If you go look at the definition of the interface mentioned, you'll see they are defined as functions instead of classes. So I changed them all to be defined as classes.toString
function, which ts doesn't like because the containing class is not a subclass of anythingany
type to some property because it's an error if there's an implicitany
and I didn't want to guess the type it should be (though i'm pretty sure it should be(function(): function|string) | string
)Array
declaration (caused by the extra-state thing mentioned below)CopyData
references which all hadtypeof
even thoughCopyData
was declared correctly as an exported member of theICopyable
namespace. this is something that could probably be fixed going forward with how we declare that propertyextraState
by adding quotes to the typedef in source and regenerating. will fix this in source in another PR.Test Coverage
none. sorry. but there are no "errors" in this file.
Additional Information
Please see caveats from last quarter as they still generally apply: #5802