npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tableau/extensions-api-types

v1.12.0

Published

Type declarations for Tableau Extensions API

Downloads

2,023

Readme

How to use the Tableau Extensions API type definitions

The Tableau Extensions API type definitions enable you to write your extension source code in TypeScript. You can use the TypeScript compiler (tsc) to transpile the TypeScript source code to JavaScript for use with your extension.

  1. Install the Extensions API type definitions. The following command installs the Extensions API type definitions (@tableau/extensions-api-types) in the node_modules folder of the current directory.
npm install @tableau/extensions-api-types
  1. Import the type definitions into your TypeScript source files. You can import modules or type definitions. For example, to import the module, Parameter, you would use the following:
import { Parameter } from '@tableau/extensions-api-types';

If you want to use Tableau enumerations as parameters to functions, or as a member variables inside class definitions, you need to import the type definitions from @tableau/extensions-api-types. You can then declare parameters or variables of that type. For example, to be able to use the DataType enum as a parameter to a function, you need to use the following import statement:

import { DataType } from '@tableau/extensions-api-types';

You can then use DataType as a type for a parameter in a class method. You can't use the fully qualified name as a parameter type (tableau.DataType), even though you can use the fully qualified name within a method.

 private foo(value: DataType) {

 switch (value) {
     case tableau.DataType.String:
         console.log(value);
         break;
     // ... do other things
 }
}

Please note that @tableau/extension-api-types submodules are subject to change. Import only from @tableau/extensions-api-types.

  1. Configure the TypeScript compiler options for your project. Set the typeRoots option to the location where you have installed the Extensions API type definitions. For example, the Samples-TypeScript extensions on GitHub use webpack and Node.js to build the samples.
{
  "compilerOptions": {
    /* Basic Options */
    "target": "esnext",
    "module": "commonjs",
    "sourceMap": true,
    "alwaysStrict": true,
    "baseUrl": "./Samples-Typescript",
    "typeRoots": ["./node_modules/@tableau", "./node_modules/@types"]
  }
}
  1. Write your extension and compile your code with the TypeScript compiler. If you need to install the compiler, see TypeScript in Visual Studio Code. Visual Studio Code supports TypeScript, but does not automatically include the TypeScript compiler (tsc).
  1. Link to the compiled JavaScript output in your extension. The TypeScript compiler transpiles the TypeScript source code to JavaScript. In your extension HTML code, link to the JavaScript file, and not your TypeScript source file.
<!-- Extensions Library  -->
<script src="../../lib/tableau.extensions.1.latest.js"></script>

<!-- The  extension code -->
<script src="./datasources.js"></script>

For more information

See Use TypeScript with the Extensions API.