Fix composition error with TypeScript

close #1381