Types for Velo by Wix
npm install @wix/wix-code-typesThis package includes scripts that generate Typescript declarations for use in wix-code's auto-completion.
Scripts:
- full-wix-code-types: generates a single JSON file with all the wix-code Typescript declarations for runtime consumption. E.g. $w definitions, The @types/node package for backend code, ES2020 declarations, various @wix module declarations etc.
- generate-model-packages-dts: generates .d.ts files for each @wix module from the _auto-velo_ flow
- Creates declarations for the 3 contexts (backend, public, page) via index.d.ts files using triple slash directives.
- The output is merged into fullCorvidTypes.json.
- generate-model-docworks-dts: generates .d.ts files for each @wix module from the _docworks_ flow
- The source of the script are JSDocs from @wix/wix-code-docs repo.
- Uses docworks.
- generate-components-data: generates a JSON file with components event handlers data.
- wix-module-list: generates 3 JSON files:
- wixModules.json: all wix-modules (EDMs) names. Used for auto-suggestions in the editor.
- deprecatedWixModules.json: all wix-modules that should be marked as deprecated, as they have SDK equivalents.
- nonDeprecatedWixModules.json: all wix-modules (EDMs) that don't have SDK equivalents. Used for auto-suggestions in the editor.
- generate-wix-sdk-list: generates a JSON file with all Wix SDK packages. Used for auto-suggestions in the editor.
- generate-wix-sdk-contextual-client: generates a special d.ts file to support contextual client for Wix SDKs in Velo environment.
- Various ast-patches: post processing of types that orginally were generated by docworks.
The build scripts runs the scripts in the following order.
```
"build": "
npm run generate-model-docworks-dts &&
npm run generate-model-packages-dts &&
npm run patch-declarations &&
npm run generate-full-wix-code-types &&
npm run generate-module-list &&
npm run generate-components-data &&
npm run typescript
",
The output is eventually:
``
dist
├── jsons
│ ├── componentsData.json
│ ├── fullWixCodeTypes.json
│ ├── deprecatedWixModules.json
│ ├── nonDeprecatedWixModules.json
│ ├── wixSdks.json
│ └── wixModules.json
└── types
├── backend
│ ├── $w.d.ts
│ ├── docworks-packages.d.ts
│ ├── index.d.ts
│ ├── wix-alarm-backend.d.ts
│ ├── wix-core-services-dev.d.ts
│ ├── ...
├── common
│ ├── $w.d.ts
│ ├── anyProperties.d.ts
│ ├── docworks-packages.d.ts
│ ├── emptyBuffer.d.ts
│ ├── wix-animations.d.ts
│ ├── ...
├── page
│ ├── $w.d.ts
│ ├── docworks-packages.d.ts
│ ├── index.d.ts
│ └── wix-packages.d.ts
└── public
├── $w.d.ts
├── docworks-packages.d.ts
├── index.d.ts
└── wix-packages.d.ts
`shell`
yarn install
yarn build
is updated automatically by @wix/wix-code-types-service which opens PRs and lands them once they pass CI.
- On every master change (landed PR), Falcon bumps the patch version on NPM
- If you want to break the contract between wix-code-types and wix-code-editor-types you will need to manually bump the major version
- By breaking the contract we mean modifying the generated JSONs structure in a way that the consumers can't handle
- To do this, manually change the package.json version field to next major or run npm version major.
- Falcon will pick this up and release the new major versionOverride wix-code-types
wix-code-types can be overridden for dev needs. To do this, simply use the query parameter wix-code-types-override. Note that wix-code-editor-types looks for the Json files in the following relative paths:- dist/jsons/fullWixCodeTypes.json
- dist/jsons/componentsData.json
- dist/jsons/wixModules.json
- dist/jsons/deprecatedWixModules.json
- dist/jsons/nonDeprecatedWixModules.json
- dist/jsons/wixSdks.json
$3
To make it easier, if you are interested in using a local build of wix-code-types, just run the following command from your local wix-code-types package:
yarn serveThen, use this query parameter:
&wix-code-types-override=http://localhost:8080/`