Incredible TypeScript type inference
This topic introduces the powerful TypeScript type inference provided by Goldfish.
The example below illustrates how TypeScript type inference works for the usePageLifeCycle
function when you integrate Goldfish into the mini program native DSL:
From the above command, you can see that:
- Although the first parameter of the
usePageLifeCycle
function is a string, the code editor that supports TypeScript can statically infer whether the first parameter is valid in the mini program page lifecycle. - The code editor that supports TypeScript can infer the type of the second parameter correctly based on the name of the first lifecycle parameter.