top | item 33140419

(no title)

uup | 3 years ago

That’s not true. You can import JS directly into TS or use ts-ignore annotations.

discuss

order

kuramitropolis|3 years ago

[deleted]

uup|3 years ago

You can directly import any valid JS module using TypeScript if you have “allowJS”: true in the compiler options of your tsconfig.json file. The comparison to FFI doesn’t make any sense. FFI requires compiling a special library that explicitly exports the C types. This is different than TS. Using TS, you can import any valid JS module without any special preparation. Also, you can’t import all compiled languages into each other using FFI. You can only import and export C-based types. There is no way to export a Go struct for consumption via FFI, for instance. All valid JS modules will work with TypeScript.