This 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 theauto-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
.
- Creates declarations for the 3 contexts (backend, public, page) via
-
generate-model-docworks-dts
: generates.d.ts
files for each@wix
module from thedocworks
flow- The source of the script are JSDocs from
@wix/wix-code-docs
repo. - Uses docworks.
- The source of the script are JSDocs from
-
components-handlers
: generates a JSON file with components event handlers data -
wix-module-list
: generates a JSON file that includes all wix-modules names - 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
│ ├── eventHandlers.json
│ ├── fullWixCodeTypes.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
yarn install
yarn build
-
wix-code-types
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
andwix-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 runnpm version major
.
- Falcon will pick this up and release the new major version
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.beta.json
- ****dist/jsons/componentsData.json
- ****dist/jsons/wixModules.beta.json
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 serve
Then, use this query parameter:
&wix-code-types-override=http://localhost:8080/