@minecraft-types/jdk.crypto.ec
v1.0.0
Published
Typescript definitions for jdk.crypto.ec from JDK 21.0.8.
Readme
@minecraft-types/jdk.crypto.ec
TypeScript type definitions for the JVM jdk.crypto.ec module (JDK 21.0.8).
Install
Install from npm or pnpm:
npm install @minecraft-types/jdk.crypto.ec
# or
pnpm add @minecraft-types/jdk.crypto.ecSetup
In your tsconfig.json, add the following to the compilerOptions section:
{
"compilerOptions": {
"types": [
"@minecraft-types/jdk.crypto.ec"
]
}
}Note: adding the types array explicitly tells TypeScript which global type packages to include. When you set compilerOptions.types it will only include the packages listed there and will not automatically include other @types/* packages (for example node). If you need other ambient types, add them to the array as well or consider using typeRoots or a project global.d.ts instead.
Using the types and handling globals
By default, this will expose the types under the Packages namespace (ex. Packages.java.io.BufferedInputStream).
If you work in an environment where the global namespace is polluted differently with Java types, you can re-namespace the types by creating a global.d.ts file in your project with the following content:
// global.d.ts
declare global {
const java: typeof Packages.java;
// Add other root namespaces as needed (e.g., javax, com, org, etc.)
// const com: typeof Packages.com;
// If your environment exposes something other than 'Packages', you can alias it here
// const SomeOtherPackages: typeof Packages;
}
export {}; // keep file a module so TS merges properlyIf instead, you'd prefer to only pollute the global namespace within that file, you can add the following to your typescript files:
declare const java: typeof Packages.java;
// Add other root namespaces as needed (e.g., javax, com, org, etc.)
// declare const com: typeof Packages.com;
// If your environment exposes something other than 'Packages', you can alias it here
// declare const SomeOtherPackages: typeof Packages;Examples
- Referencing a Java type directly from the ambient
Packagestypes:
// Uses the package name as exposed by the types
type BIS = Packages.java.io.BufferedInputStream;
declare const inStream: BIS;- Using the
javaalias from theglobal.d.tsexample:
const s: string = java.lang.String.valueOf(123);