Skip to content
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

Feature/es imports #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

oriori1703
Copy link

Migrate from commonJS to ESM

@oriori1703 oriori1703 force-pushed the feature/es-imports branch 3 times, most recently from 1ac4900 to f2b20b1 Compare February 9, 2025 21:26
Copy link
Collaborator

@hot3eed hot3eed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

"outDir": "./dist",
"strictPropertyInitialization": false,
"strictNullChecks": false,
"skipLibCheck": true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why did we add this? Same for strictPropertyInitialization and strictNullChecks.

Copy link
Author

@oriori1703 oriori1703 Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added all of those to workaround existing TS issues.

npx frida-compile index.ts -o /tmp/test.js
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (145,5): Property '#description' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (165,5): Property '#description' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (313,5): Property '#flags' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (314,5): Property '#parent' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (362,5): Property '#name' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (374,9): Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (385,5): Property '#accessFunctionPtr' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (386,5): Property '#fields' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (402,9): Type 'string | null' is not assignable to type 'string | undefined'.
  Type 'null' is not assignable to type 'string | undefined'.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (403,9): Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (470,13): Type 'null' is not assignable to type 'VTableDescriptorHeader'.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (542,5): Property '#flags' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (543,5): Property '#impl' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (604,5): Property '#numPayloadCasesAndPayloadSizeOffset' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (605,5): Property '#numEmptyCases' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (652,5): Property '#name' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (653,5): Property '#numRequirements' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (664,13): Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (696,13): Type 'null' is not assignable to type 'NativePointer'.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (723,5): Property '#protocol' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (724,5): Property '#typeRef' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (725,5): Property '#witnessTablePattern' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (726,5): Property '#flags' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/abi/metadata.ts (761,13): Type 'NativePointer | null' is not assignable to type 'NativePointer'.
  Type 'null' is not assignable to type 'NativePointer'.
/home/orip/Projects/Frida/frida-swift-bridge/basic/relativepointer.ts (11,9): Type 'RelativeDirectPointer | null' is not assignable to type 'RelativeDirectPointer'.
  Type 'null' is not assignable to type 'RelativeDirectPointer'.
/home/orip/Projects/Frida/frida-swift-bridge/basic/relativepointer.ts (25,9): Type 'RelativeIndirectablePointer | null' is not assignable to type 'RelativeIndirectablePointer'.
  Type 'null' is not assignable to type 'RelativeIndirectablePointer'.
/home/orip/Projects/Frida/frida-swift-bridge/index.ts (35,5): Type 'null' is not assignable to type 'Api'.
/home/orip/Projects/Frida/frida-swift-bridge/index.ts (36,5): Type 'null' is not assignable to type 'Error'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/api.ts (8,5): Type 'null' is not assignable to type 'Api'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/api.ts (9,5): Type 'null' is not assignable to type 'Api'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/callingconvention.ts (271,13): Type 'undefined' is not assignable to type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'undefined'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/callingconvention.ts (364,49): Object is possibly 'undefined'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/callingconvention.ts (365,48): Argument of type 'NativePointer | undefined' is not assignable to parameter of type 'NativePointerValue'.
  Type 'undefined' is not assignable to type 'NativePointerValue'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/callingconvention.ts (370,33): Object is possibly 'undefined'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/callingconvention.ts (416,20): Object is possibly 'undefined'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/callingconvention.ts (420,36): Object is possibly 'undefined'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/callingconvention.ts (422,25): Object is possibly 'undefined'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/interceptor.ts (186,39): 'callbacks.onLeave' is possibly 'undefined'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/interceptor.ts (187,17): Cannot invoke an object which is possibly 'undefined'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/interceptor.ts (187,17): The 'this' context of type 'void' is not assignable to method's 'this' of type 'InvocationContext'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/interceptor.ts (193,13): Variable 'onLeave' is used before being assigned.
/home/orip/Projects/Frida/frida-swift-bridge/lib/macho.ts (89,9): Type 'TargetMetadata | undefined' is not assignable to type 'TargetMetadata'.
  Type 'undefined' is not assignable to type 'TargetMetadata'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/macho.ts (257,17): Type 'null' is not assignable to type 'NativePointer'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/macho.ts (306,9): Type 'undefined' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/macho.ts (317,9): Type 'undefined' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/symbols.ts (29,9): Type 'undefined' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/symbols.ts (36,9): Type 'undefined' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/symbols.ts (44,9): Type 'undefined' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/symbols.ts (65,33): Argument of type 'string | null' is not assignable to parameter of type 'string'.
  Type 'null' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/symbols.ts (67,9): Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/symbols.ts (69,9): Type 'undefined' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/symbols.ts (168,9): Type 'undefined' is not assignable to type 'MethodSignatureParseResult'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/symbols.ts (210,9): Type 'undefined' is not assignable to type 'AccessorSignatureParseResult'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/types.ts (337,14): Property '$metadata' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/lib/types.ts (409,61): Argument of type 'RawFields | undefined' is not assignable to parameter of type 'RawFields'.
  Type 'undefined' is not assignable to type 'PointerSized[]'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/types.ts (436,5): Property '#payload' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/lib/types.ts (501,65): Argument of type 'RawFields | undefined' is not assignable to parameter of type 'RawFields'.
  Type 'undefined' is not assignable to type 'PointerSized[]'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/types.ts (512,50): Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/types.ts (520,29): Variable 'payload' is used before being assigned.
/home/orip/Projects/Frida/frida-swift-bridge/lib/types.ts (661,9): Type 'undefined' is not assignable to type 'FieldDetails[]'.
/home/orip/Projects/Frida/frida-swift-bridge/lib/types.ts (666,9): Type 'undefined' is not assignable to type 'FieldDetails[]'.
/home/orip/Projects/Frida/frida-swift-bridge/reflection/records.ts (7,5): Property '#numFields' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/reflection/records.ts (47,5): Property '#flags' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/reflection/records.ts (48,5): Property '#mangledTypeName' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/reflection/records.ts (49,5): Property '#fieldName' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/reflection/records.ts (78,9): Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
/home/orip/Projects/Frida/frida-swift-bridge/runtime/existentialcontainer.ts (18,5): Property '#buffer' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/runtime/existentialcontainer.ts (19,5): Property '#type' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/runtime/existentialcontainer.ts (113,5): Property '#value' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/runtime/heapobject.ts (9,14): Property 'metadata' has no initializer and is not definitely assigned in the constructor.
/home/orip/Projects/Frida/frida-swift-bridge/runtime/heapobject.ts (10,14): Property 'refCounts' has no initializer and is not definitely assigned in the constructor.

They won't show up if you try to compile test/bundle.js because of skipLibCheck, but can be verified by running : npx frida-compile index.ts -o /tmp/test.js.
Also for some reason they only show up for me when using frida-compile, but not when using tsc.

tsconfig.json Outdated
@@ -2,9 +2,13 @@
"compilerOptions": {
"lib": ["es2020"],
"target": "es2020",
"module": "commonjs",
"module": "nodenext",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we want this or es{something} (will defer to @oleavr), from the docs:

You very likely want "nodenext" for modern Node.js projects and preserve or esnext for code that will be bundled.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading more of the docs, it seems esnext (or any other es{something}) does fit better.
I changed to esnext for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants