The WebF type generation system is composed of several interconnected tasks that generate TypeScript definitions from multiple sources:
- Scans all
.d.tsfiles inbridge/core/directory - Merges them into a single
bridge/typings/webf.d.tsfile - Processes WebF-specific type annotations:
DartImpl<T>→TStaticMember<T>→TStaticMethod<T>→TSupportAsync<T>→ Generates both sync and async variantsDependentsOnLayout<T>→T
- Adds global declarations for
documentandwindow - Creates a
webfnamespace containing all type exports
- Uses Rollup with
rollup-plugin-dtsto generate types frombridge/polyfill/src - Outputs to
bridge/typings/polyfill.d.ts - Configuration in
bridge/polyfill/rollup.config.dts.js - Includes reference to
webf.d.tsfor accessing core types likeEventTarget
- References both
webf.d.tsandpolyfill.d.ts - Re-exports polyfill module exports
- Provides a unified interface for all WebF types
Runs the type generation pipeline:
series(
'merge-bridge-typings', // Generate webf.d.ts from bridge/core
'update-typings-version', // Update package version
'generate-bindings-code' // Generate C++ binding code
)Includes polyfill type generation:
series(
'generate-bindings-code',
'compile-build-tools',
'compile-polyfill',
'generate-polyfill-typings', // Generate polyfill.d.ts
'generate-polyfill-bytecode'
)-
DO NOT manually edit generated files:
bridge/typings/webf.d.ts- Generated from bridge/core/*.d.tsbridge/typings/polyfill.d.ts- Generated from polyfill TypeScript source
-
Global declarations: The
documentandwindowglobals are added in themerge-bridge-typingstask intasks.js -
Type transformations: The system automatically handles WebF-specific type annotations and generates appropriate TypeScript types
-
Testing: Run tests with
npm testin thebridge/typingsdirectory to ensure types compile correctly without DOM lib
- Regenerate all types:
node scripts/generate_binding_code.js - Generate only polyfill types:
cd bridge/typings && npm run generate - Test typings:
cd bridge/typings && npm test
The type generation scripts now include improved error handling:
-
generate_binding_code.js:
- Displays detailed error messages with stack traces
- Exits with non-zero status code on failure
- Shows specific task that failed (merge-bridge-typings, update-typings-version, or generate-bindings-code)
-
Task-level errors:
- Each gulp task provides specific error messages
- Failed builds show build tool output
- Parsing errors include file paths and line numbers
-
Common errors:
- Missing dependencies: Run
npm installin the appropriate directory - TypeScript parsing errors: Check the source .d.ts files for syntax errors
- File not found: Ensure all required directories exist
- Missing dependencies: Run