{"id":26455,"library":"swift-js","title":"swift-js","description":"A Swift-to-JavaScript transpiler (v0.1.0) that converts a subset of Swift syntax into JavaScript. Provides basic support for classes, functions, variables, and control flow. Not actively maintained; experimental status. Differentiators vs alternative transpilers (e.g., Kotlin/JS, Scala.js) include minimal dependencies and a simple CLI workflow, but lacks robust error handling, Unicode support, and standard library mapping. Suitable for proof-of-concept projects only.","status":"abandoned","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/ankurp/swift-js","tags":["javascript"],"install":[{"cmd":"npm install swift-js","lang":"bash","label":"npm"},{"cmd":"yarn add swift-js","lang":"bash","label":"yarn"},{"cmd":"pnpm add swift-js","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only support; CJS require() fails due to missing default export.","wrong":"const swift = require('swift-js');","symbol":"transpile","correct":"import { transpile } from 'swift-js';"},{"note":"Default export is the transpile function; named export also available.","wrong":"const swiftjs = require('swift-js').default;","symbol":"default","correct":"import swiftjs from 'swift-js';"},{"note":"Class export for advanced usage; requires ESM import.","wrong":"const Transpiler = require('swift-js').SwiftJSTranspiler;","symbol":"SwiftJSTranspiler","correct":"import { SwiftJSTranspiler } from 'swift-js';"}],"quickstart":{"code":"import { transpile } from 'swift-js';\n\nconst swiftCode = `\nfunc greet(name: String) -> String {\n    return \"Hello, \\(name)!\"\n}\nprint(greet(name: \"World\"))\n`;\n\ntry {\n  const jsCode = transpile(swiftCode);\n  console.log(jsCode);\n} catch (err) {\n  console.error('Transpilation error:', err.message);\n}","lang":"typescript","description":"Basic example transpiling a Swift function to JavaScript, including error handling for transpilation failures."},"warnings":[{"fix":"Manually replace \\(...) with template literal syntax ${...} after transpilation.","message":"Swift string interpolation escaped incorrectly in JavaScript output.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Handle undefined values manually in generated JS code.","message":"Does not support Swift's Optional types; nil may be mapped to undefined incorrectly.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Migrate to a supported transpiler.","message":"Package has not been updated since 2020; consider using modern alternatives like Kotlin/JS or TypeScript.","severity":"deprecated","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install via 'npm install swift-js' from npm registry.","cause":"Package not installed or not in a valid npm registry.","error":"Cannot find module 'swift-js'"},{"fix":"Use 'import { transpile } from 'swift-js';' or set 'type': 'module' in package.json.","cause":"Using CommonJS require() with an ESM-only package.","error":"'require' is not defined in ES module scope"},{"fix":"Rewrite unsupported Swift constructs using basic function definitions.","cause":"Swift syntax not supported by the transpiler (e.g., closures with shorthand arguments).","error":"Unexpected token: '('"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}