0.5.13 • Published 3 years ago

@goldpage/typescript v0.5.13

Weekly downloads
15
License
-
Repository
github
Last release
3 years ago

Goldpage + TypeScript = :heart:

@goldpage/typescript

Use Goldpage with TypeScript.

Usage

Install @goldpage/typescript.

$ npm install @goldpage/typescript

The @goldpage/typescript plugin is automatically loaded.

Configure TypeScript:

module.exports = {
  typescript: {
    // Syntax transformation is done with `@babel/preset-typescript`
    // Options:
    babelPresetTypescript: {
      isTSX: true, // default value
      allExtensions: true, // default value
    },

    // Type checking is done with `fork-ts-checker-webpack-plugin`
    // Options:
    forkTsCheckerWebpackPlugin: {
      // To enable type checking set `enable: true`
      enable: true,
    },
  },
};

Example

// ./example/pages/hello.page.tsx

import * as React from "react";

interface HelloProps { compiler: string; framework: string; }

const Hello = (props: HelloProps) => <h3>Hello from {props.compiler} and {props.framework}!</h3>;

export default {
    route: '/',
    view: () => <Hello compiler="TypeScript" framework="React" />,
    renderToDom: false,
};
// ./example/goldpage.config.js

module.exports = {
  typescript: {
    // Syntax transformation is done with `@babel/preset-typescript`
    // Options:
    babelPresetTypescript: {
      isTSX: true, // default value
      allExtensions: true, // default value
    },

    // Type checking is done with `fork-ts-checker-webpack-plugin`
    // Options:
    forkTsCheckerWebpackPlugin: {
      // To enable type checking set `enable: true`
      enable: true,
    },
  },
};