# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 # TypeScript 7 is the native port of the compiler, written in Go. The # "typescript" npm package is now only a thin JavaScript launcher (bin/tsc) # plus the unstable IPC API under dist/; the compiler itself is a prebuilt, # statically linked Go executable shipped in a per-platform package, # @typescript/typescript--, that the launcher resolves through # Node's module resolution. # # This is Microsoft's npm build, installed as published. dev-lang/typescript # is the same compiler built from source; both own /usr/bin/tsc, so they # block each other. Pick this one for the npm launcher and the dist/ IPC API, # which the source package does not install. # # There is no tsserver.js and no lib/typescript.js any more, and the package's # main export only reports the version. Consumers that drive tsserver or load # the JavaScript compiler API (typescript-language-server, editor plugins, # ts-node and friends) must depend on /dev/null || die unpack "${MY_P}-linux-x64.tgz" popd >/dev/null || die } src_compile() { # Prebuilt; nothing to compile. : } src_install() { # Same location as the 6.x series, which is installed with # npm --global --prefix=/usr: always lib/, never lib64/. local dest=/usr/lib/node_modules/${MY_PN} local platdir=${dest}/node_modules/@typescript/typescript-linux-x64 insinto "${dest}" doins -r bin lib dist vendor package.json fperms 0755 "${dest}"/bin/tsc # getExePath.js resolves @typescript/typescript-/package.json # from lib/, so a node_modules/ nested inside the package is found first. # The Go executable reads the lib.*.d.ts files that sit next to it. insinto "${platdir}" doins -r "${WORKDIR}"/platform/package/{lib,package.json} fperms 0755 "${platdir}"/lib/tsc dosym -r "${dest}"/bin/tsc /usr/bin/tsc # The executable itself, under the name both TypeScript 7 packages share: # consumers that need the binary rather than the Node launcher (Chromium # copies it into its tree) resolve /usr/bin/tsgo with realpath. dosym -r "${platdir}"/lib/tsc /usr/bin/tsgo dodoc README.md NOTICE.txt }