Skip to main content

2 posts tagged with "javascript"

View All Tags

How we improved our apidocs with Typedoc groups and categories

· 11 min read
Simon Porritt
JsPlumb Development

JsPlumb uses the excellent Typedoc documentation generator to create our API documentation, but since we adopted it last year we haven't really made the most of it. We would run Typedoc over our codebase with the default settings, and the result is a page in which everything is listed alphabetically, grouped by Enumerations Classes, Interfaces, etc.

It can be a useful page - if you know what you're looking for. But it doesn't lend itself very well to browsing, and browseable docs are great, because they lead to discovery.

TS4111 - noPropertyAccessFromIndexSignature

· 2 min read
Simon Porritt
JsPlumb Development

While working on an Angular version of our popular Gantt chart demonstration this morning I stumbled across a Typescript linting issue whose purpose is not at all clear to me.

Say I have this interface for a person:

export interface Person {    
firstName:string
lastName:string
}

and this for a serialized person:

export interface Person {    
firstName:string
lastName:string
fullName:string
}

Now I want to write a serializer to export a bunch of these people:

export function serializePeople(persons:Array<Person>):string {
return persons.map(p => {
return {
fullName:`${p.firstName} ${p.lastName}`,
firstName:p.firstName,
lastName:p.lastName
}
})
}

This looks ok, right? Well in fact the default settings for Angular's tsconfig.json cause an error:

Property 'firstName' comes from an index signature, so it must be accessed with ['firstName']