Skip to content
Gx
GitHub

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

dashboard/charts.go
package dashboard

type RevenueChartProps struct {
	Title string `json:"title"`
	Data  []int  `json:"data"`
}
dashboard/RevenueChart.ts
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:

gx check after gx generate
dashboard/RevenueChart.ts:4:40: GX6005: TS2339: Property 'toUpperCase' does not exist on type 'number[]'.

Fix

  1. Correct the island code. The message is the message of the TypeScript compiler.
  2. For a prop that is not in the props type, add the field to the Go struct and run gx generate.
  3. For different compiler options, write a tsconfig.json in the app directory. gx check then checks that project.