- Error
- Reported by the type checker
TS1070
'{0}' modifier cannot appear on a type member.
A modifier such as `public` or `static` is used on a member of an interface or type literal. Type members cannot have these modifiers.
What it means
Interfaces and type literals describe shapes; their members have no visibility and are never static. Of the modifiers, only readonly is allowed on a type member. Accessibility, static, abstract, async, export, declare and override are reported here.
Example
export interface Point {
public x: number;
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(2,3): error TS1070: 'public' modifier cannot appear on a type member.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Delete the modifier:
x: number. - If you need
privateorstaticmembers, use a class.