GX6005: TypeScript error in an island
The TypeScript compiler found an error in an island file.
Cause
gx check runs the TypeScript compiler on each island. The compiler is native code that gx downloads and pins in gx.lock, so the check needs no node. The message starts with the error code of TypeScript.
The props type of an island comes from its Go struct. gx generate writes it to <Name>.props.ts. An island that reads a prop that the struct does not have gets this diagnostic.
Example
package dashboard
type RevenueChartProps struct {
Title string `json:"title"`
Data []int `json:"data"`
}import type { Mount } from "./RevenueChart.props";
const mount: Mount = (el, { title, data }) => {
el.textContent = title + ": " + data.toUpperCase();
};
export default mount;gx generate writes the props file. Then gx check reports:
dashboard/RevenueChart.ts:4:40: GX6005: TS2339: Property 'toUpperCase' does not exist on type 'number[]'.Fix
- Correct the island code. The message is the message of the TypeScript compiler.
- For a prop that is not in the props type, add the field to the Go struct and run
gx generate. - For different compiler options, write a
tsconfig.jsonin the app directory.gx checkthen checks that project.