typescript issues !
AaronNGray opened this issue · comments
@gobengo - getting typescipt issues both with current 'npm install typescript@4.9.4', and original typescript@2.9.2 !
C:\Users\aaron\GitHub\distbin>npm install
up to date, audited 345 packages in 2s
29 packages are looking for funding
run `npm fund` for details
5 vulnerabilities (2 moderate, 2 high, 1 critical)
To address issues that do not require attention, run:
npm audit fix
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
C:\Users\aaron\GitHub\distbin>npm run test
> distbin@1.3.0 test
> ts-node test
(node:4628) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
C:\Users\aaron\GitHub\distbin\node_modules\ts-node\dist\index.js:316
return old(m, filename);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\aaron\GitHub\distbin\node_modules\node-fetch\src\index.js from C:\Users\aaron\GitHub\distbin\test\ldn.ts not supported.
Instead change the require of index.js in C:\Users\aaron\GitHub\distbin\test\ldn.ts to a dynamic import() which is available in all CommonJS modules.
at require.extensions.<computed> [as .js] (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\dist\index.js:316:20)
at Object.<anonymous> (C:\Users\aaron\GitHub\distbin\test\ldn.ts:13:22)
at m._compile (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\dist\index.js:321:29)
at require.extensions.<computed> [as .ts] (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\dist\index.js:323:16)
at C:\Users\aaron\GitHub\distbin\test\index.ts:17:42
at async Promise.all (index 0)
C:\Users\aaron\GitHub\distbin>tsc --version
Version 4.9.4
C:\Users\aaron\GitHub\distbin>npm install typescript@2.9.2
up to date, audited 345 packages in 901ms
29 packages are looking for funding
run `npm fund` for details
5 vulnerabilities (2 moderate, 2 high, 1 critical)
To address issues that do not require attention, run:
npm audit fix
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
C:\Users\aaron\GitHub\distbin>npm run test
> distbin@1.3.0 test
> ts-node test
(node:38536) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
C:\Users\aaron\GitHub\distbin\node_modules\ts-node\dist\index.js:316
return old(m, filename);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\aaron\GitHub\distbin\node_modules\node-fetch\src\index.js from C:\Users\aaron\GitHub\distbin\test\ldn.ts not supported.
Instead change the require of index.js in C:\Users\aaron\GitHub\distbin\test\ldn.ts to a dynamic import() which is available in all CommonJS modules.
at require.extensions.<computed> [as .js] (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\dist\index.js:316:20)
at Object.<anonymous> (C:\Users\aaron\GitHub\distbin\test\ldn.ts:13:22)
at m._compile (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\dist\index.js:321:29)
at require.extensions.<computed> [as .ts] (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\dist\index.js:323:16)
at C:\Users\aaron\GitHub\distbin\test\index.ts:17:42
at async Promise.all (index 0)
C:\Users\aaron\GitHub\distbin>
@gobengo - I did have a look at solving them as I wanted to put up an instance online but it was not obvious.
C:\Users\aaron\GitHub\distbin>npm run tsc
> distbin@1.3.0 tsc
> tsc
node_modules/highlight.js/types/index.d.ts:4:1 - error TS1084: Invalid 'reference' directive syntax.
4 /// <reference lib="dom" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/highlight.js/types/index.d.ts:55:54 - error TS1110: Type expected.
55 either: (...args: (RegExp | string)[] | [...(RegExp | string)[], RegexEitherOptions]) => string,
~~~
node_modules/node-fetch/@types/index.d.ts:21:87 - error TS1005: ']' expected.
21 export type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>;
~
node_modules/node-fetch/@types/index.d.ts:21:95 - error TS1005: '>' expected.
21 export type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>;
~
node_modules/node-fetch/@types/index.d.ts:21:96 - error TS1109: Expression expected.
21 export type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>;
~
node_modules/node-fetch/@types/index.d.ts:21:98 - error TS1109: Expression expected.
21 export type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>;
~
node_modules/node-fetch/@types/index.d.ts:21:126 - error TS1005: '(' expected.
21 export type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>;
~
C:\Users\aaron\GitHub\distbin>npm install typescript@4.9.4
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: distbin@1.3.0
npm WARN Found: typescript@2.9.2
npm WARN node_modules/typescript
npm WARN peer typescript@"*" from tsc-watch@1.1.39
npm WARN node_modules/tsc-watch
npm WARN dev tsc-watch@"^1.0.22" from the root project
npm WARN 8 more (tslint, tslint-eslint-rules, tsutils, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer typescript@"^2.2.0 || ^3.0.0" from tslint-eslint-rules@5.4.0
npm WARN node_modules/tslint-eslint-rules
npm WARN dev tslint-eslint-rules@"^5.4.0" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: distbin@1.3.0
npm WARN Found: typescript@2.9.2
npm WARN node_modules/typescript
npm WARN peer typescript@"*" from tsc-watch@1.1.39
npm WARN node_modules/tsc-watch
npm WARN dev tsc-watch@"^1.0.22" from the root project
npm WARN 8 more (tslint, tslint-eslint-rules, tsutils, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer typescript@"^2.1.0 || ^3.0.0" from tslint-microsoft-contrib@6.2.0
npm WARN node_modules/tslint-microsoft-contrib
npm WARN dev tslint-microsoft-contrib@"^6.1.0" from the root project
changed 1 package, and audited 345 packages in 1s
29 packages are looking for funding
run `npm fund` for details
5 vulnerabilities (2 moderate, 2 high, 1 critical)
To address issues that do not require attention, run:
npm audit fix
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
C:\Users\aaron\GitHub\distbin>npm run tsc
> distbin@1.3.0 tsc
> tsc
bin/server.ts:52:30 - error TS2345: Argument of type 'IDistbinConfig & { externalUrl: string; }' is not assignable to parameter of type '{ activities?: Map<string, object>; inbox?: Map<string, object>; inboxFilter?: (obj: ASObject) => Promise<boolean>; externalUrl?: string; internalUrl?: string; deliverToLocalhost?: boolean; }'.
Types of property 'activities' are incompatible.
Type 'IAsyncMap<string, any>' is missing the following properties from type 'Map<string, object>': [Symbol.iterator], [Symbol.toStringTag]
52 const apiHandler = distbin(Object.assign(
~~~~~~~~~~~~~~
53 distbinConfig,
~~~~~~~~~~~~~~~~~~
54 ( ! distbinConfig.externalUrl ) && { externalUrl },
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55 ))
~~~
src/activitypub.ts:538:25 - error TS2339: Property 'inbox' does not exist on type 'unknown'.
538 const inbox = subject.inbox;
~~~~~
src/activitypub.ts:640:31 - error TS2339: Property 'inbox' does not exist on type 'unknown'.
640 const inbox = actor.inbox;
~~~~~
src/distbin-html/an-activity.ts:31:10 - error TS2614: Module '"highlight.js"' has no exported member 'highlightAuto'. Did you mean to use 'import highlightAuto from "highlight.js"' instead?
31 import { highlightAuto } from "highlight.js"
~~~~~~~~~~~~~
src/distbin-html/home.ts:405:5 - error TS2322: Type 'number' is not assignable to type 'never'.
405 location[k] = parseFloat(fieldVal);
~~~~~~~~~~~
src/index.ts:69:43 - error TS2322: Type 'Map<string, object>' is not assignable to type 'ActivityMap'.
Type 'object' is not assignable to type 'Activity | DistbinActivity'.
69 ["/recent", () => recentHandler({ activities })],
~~~~~~~~~~
src/index.ts:372:42
372 function recentHandler({ activities }: { activities: ActivityMap }) {
~~~~~~~~~~
The expected type comes from property 'activities' which is declared here on type '{ activities: ActivityMap; }'
src/index.ts:72:32 - error TS2322: Type 'Map<string, object>' is not assignable to type 'ActivityMap'.
72 () => inboxHandler({ activities, inbox, inboxFilter, externalUrl }),
~~~~~~~~~~
src/index.ts:408:3
408 activities: ActivityMap;
~~~~~~~~~~
The expected type comes from property 'activities' which is declared here on type '{ activities: ActivityMap; externalUrl: string; inbox: ActivityMap; inboxFilter?: (obj: ASObject) => Promise<boolean>; }'
src/index.ts:72:44 - error TS2322: Type 'Map<string, object>' is not assignable to type 'ActivityMap'.
72 () => inboxHandler({ activities, inbox, inboxFilter, externalUrl }),
~~~~~
src/index.ts:410:3
410 inbox: ActivityMap;
~~~~~
The expected type comes from property 'inbox' which is declared here on type '{ activities: ActivityMap; externalUrl: string; inbox: ActivityMap; inboxFilter?: (obj: ASObject) => Promise<boolean>; }'
src/index.ts:78:15 - error TS2322: Type 'Map<string, object>' is not assignable to type 'ActivityMap'.
78 activities,
~~~~~~~~~~
src/index.ts:605:3
605 activities: ActivityMap;
~~~~~~~~~~
The expected type comes from property 'activities' which is declared here on type '{ activities: ActivityMap; externalUrl: string; internalUrl: string; deliverToLocalhost: boolean; }'
src/index.ts:86:47 - error TS2322: Type 'Map<string, object>' is not assignable to type 'Map<string, Activity>'.
Property 'type' is missing in type '{}' but required in type 'Activity'.
86 () => publicCollectionPageHandler({ activities, externalUrl }),
~~~~~~~~~~
src/activitystreams/types.ts:117:10
117 public type: ASObjectType<"Activity" | ActivitySubtype>;
~~~~
'type' is declared here.
src/index.ts:923:3
923 activities: Map<string, Activity>;
~~~~~~~~~~
The expected type comes from property 'activities' which is declared here on type '{ activities: Map<string, Activity>; externalUrl: string; }'
src/index.ts:90:43 - error TS2322: Type 'Map<string, object>' is not assignable to type 'ActivityMap'.
90 () => publicCollectionHandler({ activities, externalUrl }),
~~~~~~~~~~
src/index.ts:747:3
747 activities: ActivityMap;
~~~~~~~~~~
The expected type comes from property 'activities' which is declared here on type '{ activities: ActivityMap; externalUrl: string; }'
src/index.ts:97:15 - error TS2322: Type 'Map<string, object>' is not assignable to type 'ActivityMap'.
97 activities,
~~~~~~~~~~
src/index.ts:248:3
248 activities: ActivityMap;
~~~~~~~~~~
The expected type comes from property 'activities' which is declared here on type '{ activities: ActivityMap; activityUuid: string; format: string; externalUrl: string; }'
src/index.ts:107:31 - error TS2322: Type 'Map<string, object>' is not assignable to type 'ActivityMap'.
107 activityHandler({ activities, activityUuid, externalUrl }),
~~~~~~~~~~
src/index.ts:199:3
199 activities: ActivityMap;
~~~~~~~~~~
The expected type comes from property 'activities' which is declared here on type '{ activities: ActivityMap; activityUuid: string; externalUrl: string; }'
src/index.ts:112:38 - error TS2322: Type 'Map<string, object>' is not assignable to type 'ActivityMap'.
112 activityRepliesHandler({ activities, activityUuid, externalUrl }),
~~~~~~~~~~
src/index.ts:268:3
268 activities: ActivityMap;
~~~~~~~~~~
The expected type comes from property 'activities' which is declared here on type '{ activities: ActivityMap; activityUuid: string; externalUrl: string; }'
test/activitystreams/index.ts:82:13 - error TS2322: Type '{ height: number; href: string; mediaType: string; type: "Link"; width: number; }' is not assignable to type 'OneOrMore<string | ASLink | ASImage>'.
Object literal may only specify known properties, and 'height' does not exist in type 'ASLink | ASImage | (string | ASLink | ASImage)[]'.
82 height: 250,
~~~~~~~~~~~
test/activitystreams/index.ts:235:7 - error TS2322: Type '{ id: string; name: string; type: ("Person" | "vcard:Individual")[]; "vcard:family-name": string; "vcard:given-name": string; }' is not assignable to type 'ASValue'.
Object literal may only specify known properties, and '"vcard:family-name"' does not exist in type 'ASLink | ASObject'.
235 "vcard:family-name": "Smith",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/activitystreams/types.ts:118:10
118 public actor?: ASValue;
~~~~~
The expected type comes from property 'actor' which is declared here on type 'Extendable<Activity>'
test/federation.ts:45:33 - error TS2339: Property 'items' does not exist on type 'unknown'.
45 assert.equal(parentActorInbox.items.length, 1)
~~~~~
test/ldn.ts:94:35 - error TS2339: Property 'id' does not exist on type 'unknown'.
94 assert.notEqual(gotNotification.id, notification.id)
~~
test/ldn.ts:137:39 - error TS2339: Property 'id' does not exist on type 'unknown'.
137 assert.notEqual(fetchedNotification.id, notification["@id"], "notification got an unambiguous id provisioned")
~~
test/ldn.ts:138:21 - error TS2322: Type 'unknown' is not assignable to type 'object'.
138 assert(!("@id" in fetchedNotification), "fetchedNotification does not have a @id")
~~~~~~~~~~~~~~~~~~~
Found 20 errors in 8 files.
Errors Files
1 bin/server.ts:52
2 src/activitypub.ts:538
1 src/distbin-html/an-activity.ts:31
1 src/distbin-html/home.ts:405
9 src/index.ts:69
2 test/activitystreams/index.ts:82
1 test/federation.ts:45
3 test/ldn.ts:94
C:\Users\aaron\GitHub\distbin>
C:\Users\aaron\GitHub\distbin>npm run start:ts-node
> distbin@1.3.0 start:ts-node
> ts-node bin/server.ts
C:\Users\aaron\GitHub\distbin\node_modules\ts-node\src\index.ts:253
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
bin/server.ts(52,30): error TS2345: Argument of type 'IDistbinConfig & { externalUrl: string; }' is not assignable to parameter of type '{ activities?: Map<string, object>; inbox?: Map<string, object>; inboxFilter?: (obj: ASObject) => Promise<boolean>; externalUrl?: string; internalUrl?: string; deliverToLocalhost?: boolean; }'.
Types of property 'activities' are incompatible.
Type 'IAsyncMap<string, any>' is missing the following properties from type 'Map<string, object>': [Symbol.iterator], [Symbol.toStringTag]
at createTSError (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\src\index.ts:253:12)
at getOutput (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\src\index.ts:363:40)
at Object.compile (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\src\index.ts:551:11)
at Module.m._compile (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\src\index.ts:435:43)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Object.require.extensions.<computed> [as .ts] (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\src\index.ts:438:12)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Function.Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at Object.<anonymous> (C:\Users\aaron\GitHub\distbin\node_modules\ts-node\src\bin.ts:147:12)
C:\Users\aaron\GitHub\distbin>