-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
TypeScript interface are stripped away when being transpiled. This is a big waste of resource because the interface-validator's syntax is adopted from TypeScript's interface syntax.
Write a Webpack loader to transform some special syntax to using interface-validator. Here are a few options:
- Detect
instanceofagainst interfaces. For example
interface Product {
name: string;
price?: {
value: number;
currency: string;
}
}
obj instanceof Product;Will be transformed to
interfaceValidator.validate(obj, {
name: 'string',
'price?': {
value: 'number',
currency: 'string'
}
});I don't know how to make tsc run pre-compile hooks yet. If that is achievable, I can write a separate module for pre-compile processing first. That'll make this usable outside Webpack.
8eecf0d2 and iro88