TypeScript is a strongly-typed superset of JavaScript developed
by Microsoft. It adds static typing, classes, interfaces
and other features to JavaScript and then compiles down
to plain JavaScript that runs in any browser.
TypeScript is especially useful for data retrieval, list
updates and other client‑side operations, and we often
use it in custom solutions. As we can build custom object types and interfaces with TypeScript,
we can model data to ensure that it is processed and stored
properly.The SPFx editions of our standard
solutions also use TypeScript under the hood.
Why TypeScript?
Type Safety: Any errors are catched at compilation
time, not at runtime.
Better IDE Support: Autocomplete, refactoring
and navigation.
Modern Features: Use ES6+ features while
ensuring backward compatibility with older browsers.
Documentation: Types serve as inline documentation
Large Codebase Management: Essential for
enterprise applications.
TypeScript Compilation Pipeline
Browsers cannot execute TypeScript, but they can
execute the JavaScript code emitted by the compiler. Therefore, we need to use compilation. We first write TypeScript (.ts) code with types, e.g. a
class with typed fields. The compiler step (tsc or ts-loader)
verifies that the code matches the declared types, which
catches errors, and converts the TypeScript syntax into
plain JavaScript (.js), which can be run by a browser.
Type definitions (.d.ts) are “type-only” files that
describe the shapes of APIs for the TypeScript checker and
editor tooling. They help TypeScript understand libraries
(including JS libraries) during type checking, but they
are not executed at runtime.
All kalmstrom.com standard products
are available as SPFx editions. Some of our many custom solutions
that also use TypeScript are: