Registry / aws / jsii-sampiler

jsii-sampiler

JSON →
library0.20.6jsnpmunverified

jsii-sampiler is a utility for transcribing TypeScript code snippets into other jsii-supported languages (Java, C#, Python, Go, etc.). It is part of the AWS jsii ecosystem and works in tandem with jsii-pacmak for documentation generation. The latest stable version (v1.x) is actively maintained with frequent bug fix releases. It uses grammatical and type-aware translation for compiling or non-compiling samples and supports void masking to hide boilerplate. Its key differentiator is deep integration with the jsii type system, enabling accurate multi-language translations beyond simple text transformation.

npm install jsii-sampiler
INSTALL
IMPORT
SIG · JSII-SAMPILER
J
jsii-sampiler
awsjavascriptv0.20.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sampile
import { sampile } from 'jsii-sampiler'
const { sampile } = require('jsii-sampiler')
ESM-only since v1.x; CommonJS require not supported.
Sampiler
import { Sampiler } from 'jsii-sampiler'
import Sampiler from 'jsii-sampiler'
Sampiler is a named export, not default.
TypeScriptSnippet
import { TypeScriptSnippet } from 'jsii-sampiler'
TypeScript type import; use 'import type' if only used as a type.

Basic usage: translate a TypeScript snippet to Python using the sampile function.

import { sampile } from 'jsii-sampiler'; // TypeScript code snippet to translate const tsCode = ` const greeting: string = 'Hello'; console.log(greeting); `; // Translate to Python const pythonCode = sampile(tsCode, 'python'); console.log(pythonCode); // Output: greeting = 'Hello' // print(greeting)
jsii-sampiler --version
Debug
Known issues
breakingVersion 1.x dropped support for Node 10; require Node >= 10.3.0.
fix
Upgrade Node to >=10.3.0 (but ideally use current LTS).
affects: >=1.0.0
gotchavoid masking directives are removed in output but affect translation; incorrect placement may produce invalid code.
fix
Ensure void expressions are used only where valid JavaScript/TypeScript syntax allows.
affects: >=0.1.0
gotchaNon-compiling samples lose type information; struct fields, nested types, and dictionary vs struct disambiguation may be incorrect.
fix
Provide compilable samples with full type annotations for best results.
affects: >=0.1.0
deprecatedThe 'Sample' class from earlier versions is deprecated; use 'sampile' function directly.
fix
Replace Sample.sampile() with import { sampile } from 'jsii-sampiler'.
affects: >=0.15.0
Errors
Common errors & fixes
SyntaxError: Unexpected token 'void'
Using void masking outside of allowed contexts (e.g., expression positions).
fix
Move void directives to statement or comma expression positions where void is syntactically valid.
Cannot find module 'jsii-sampiler' or its corresponding type declarations.
Missing installation or incorrect import path.
fix
npm install jsii-sampiler and use import { sampile } from 'jsii-sampiler' (ESM).
TypeError: sampile is not a function
Improper import (e.g., default import instead of named).
fix
Use import { sampile } from 'jsii-sampiler', not import sampile from 'jsii-sampiler'.
Upgrade
Version history
0.20.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
Amazon
1
Resources
jsii-sampiler — npm install jsii-sampiler · libregistry