- Error
- Reported by the lexer and parser
TS1477
An instantiation expression cannot be followed by a property access.
A generic function with explicit type arguments (an instantiation expression) is followed by `.property`. Wrap it in parentheses or drop the type arguments.
What it means
fn<string> without a call is an instantiation expression: it produces fn with its type parameters fixed. It can't be followed directly by a property access such as .name.
Example
function id<T>(x: T): T {
return x;
}
export const n = id<string>.name;
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(5,20): error TS1477: An instantiation expression cannot be followed by a property access.
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
- Wrap it:
(id<string>).name. - Or access the property on the function itself:
id.name.