-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
Upgrade typescript to version 4 #4624
base: master
Are you sure you want to change the base?
Conversation
It looks like TypeScript 4 might have broken our metadata generation, which isn't that surprising I guess.
Revert before merging. Just want to move on to the next set of errors
I absolutely must remember to fix the typedoc / :help theme before merging. I think we might have got onto real errors now: src/lib/messaging.ts:81:22 - error TS2344: Type 'Root[Type][Command]' does not satisfy the constraint '(...args: any) => any'.
Type 'Root[Type][keyof Root[Type]]' is not assignable to type '(...args: any) => any'.
Type 'Root[Type][string] | Root[Type][number] | Root[Type][symbol]' is not assignable to type '(...args: any) => any'.
Type 'Root[Type][string]' is not assignable to type '(...args: any) => any'.
Type 'Root[keyof Root][string]' is not assignable to type '(...args: any) => any'.
Type 'Root[string][string] | Root[number][string] | Root[symbol][string]' is not assignable to type '(...args: any) => any'.
Type 'Root[string][string]' is not assignable to type '(...args: any) => any'.
81 args: Parameters<Root[Type][Command]>
~~~~~~~~~~~~~~~~~~~
src/lib/messaging.ts:91:15 - error TS2344: Type 'Root[Type][Command]' does not satisfy the constraint '(...args: any) => any'.
Type 'Root[Type][keyof Root[Type]]' is not assignable to type '(...args: any) => any'.
Type 'Root[Type][string] | Root[Type][number] | Root[Type][symbol]' is not assignable to type '(...args: any) => any'.
Type 'Root[Type][string]' is not assignable to type '(...args: any) => any'.
Type 'Root[keyof Root][string]' is not assignable to type '(...args: any) => any'.
Type 'Root[string][string] | Root[number][string] | Root[symbol][string]' is not assignable to type '(...args: any) => any'.
Type 'Root[string][string]' is not assignable to type '(...args: any) => any'.
91 ): ReturnType<Root[Type][Command]> {
~~~~~~~~~~~~~~~~~~~
src/lib/messaging.ts:92:12 - error TS2349: This expression is not callable.
Type '{}' has no call signatures.
92 return root[message.type][message.command](...message.args)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib/messaging.ts:98:33 - error TS2322: Type 'Root' is not assignable to type 'object'.
98 if (message.type in root) {
~~~~
src/lib/messaging.ts:95:31
95 export function setupListener<Root>(root: Root) {
~~~~
This type parameter might need an `extends object` constraint.
Found 4 errors in the same file, starting at: src/lib/messaging.ts:81 I'll try to look at these remaining errors again tomorrow ... tonight I'm finding them pretty impenetrable. |
Here is a pathetic attempt to fix typing |
The messages object in background.ts implicitly had a type { [key: string]: { [key: string]: (...args: any) => any } }, and was used as such in messaging.ts. Now that TypeScript is updated, it got angry because the imported excmds_background and statsLogger are not strictly { [key: string]: (...args: any) => any }. For excmd_functions the problem were consts which are not functions. I namespaced all functions and if we import only that namespace and use it in messaging, typescript will be happy. I know namespaces are discouraged but i don't know of other ways to separate functions from other parts of a file without creating a new file for them. As for logger, i used a nasty cast because what else can we do? Using namespace also pisses off lint, and pretty seems to break everything, so this patch is purely to make build work.
There are a fair few left to do - anything with _src_ in it is wrong
For some reason all the excmd doc-comments seem to have disappeared, but they work fine for the lib/config page. |
I think all remaining linting errors are real errors
79f2182
to
ca106ab
Compare
It seems we can get away without namespace if we stop exporting anything but functions. I'm not sure if we need those exports, but it builds and works more-or-less. |
Needed to do this to make the new theme, apparently
One day we should probably work out how to make the new runner, circus, fail fast
So long as you don't try to use the command line on a non-Tridactyl page 👀. Tridactyl pages get access to the background script so presumably there's some problem with the messaging. I applied the patch and pushed it to a different branch 7d6fcc8 because it was slightly annoying to rebase and I didn't want to have to do it again if we get it working :) |
Oops, you're right. But i guess we still need a solution without namespace(because it looks like someday they'll be deprecated), so i'll look into it. |
There's something wrong with the e2e tests
in e2e.test.ts should make them run locally, I'll try to look tomorrow |
Build fails, presumably something that has changed for the metadata generator from ts 3 -> ts 4.
Logs:
Includes #4623
Closes #4622