When extra properties are an error
Which line or lines does TypeScript report as an error?
type User = { name: string }
const data = { name: 'Ana', age: 30 }
const a: User = data // line A
const b: User = { name: 'Ana', age: 30 } // line BDiscussion 0
Join free to post in the discussion.
Related questions
- TypeScript types at runtimeFrontend Developer
- Type inferred from a letFrontend Developer
- Narrowing a union with typeofFrontend Developer
- Declaring the same interface twiceFrontend Developer
- Type of an optional parameterFrontend Developer
- Pushing to a readonly arrayFrontend Developer
- Type of a const stringFrontend Developer
- What as const does to an arrayFrontend Developer