This is a type alias - it's used to give another name to a type.

(Compare type vs interface here)

In your example, feline will be the type of whatever cat is.

Here's a more full fledged example:

interface Animal {
    legs: number;
}

const cat: Animal = { legs: 4 };

export type feline = typeof cat;

feline will be the type Animal, and you can use it as a type wherever you like.

const someFunc = (cat: feline) => {
    doSomething(cat.legs);
};

export simply exports it from the file. It's the same as doing this:

type feline = typeof cat;

export {
    feline
};
Answer from James Monger on Stack Overflow
🌐
TypeScript
typescriptlang.org › docs › handbook › release-notes › typescript-3-8.html
TypeScript: Documentation - TypeScript 3.8
import type only imports declarations to be used for type annotations and declarations. It always gets fully erased, so there’s no remnant of it at runtime. Similarly, export type only provides an export that can be used for type contexts, and is also erased from TypeScript’s output.
Discussions

[request] allow `export type * from`
Fix AvailableA PR has been opened ... a team member to investigate its status.SuggestionAn idea for TypeScriptAn idea for TypeScript ... TS1383: Only named exports may use 'export type'.... More on github.com
🌐 github.com
24
March 6, 2020
`export type * from 'somewhere'`
Suggestion 🔍 Search Terms typescript export type star ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This ... More on github.com
🌐 github.com
13
April 1, 2022
What does export type mean in TypeScript? - Ask a Question - TestMu AI Community
I came across the following syntax ... but I can’t find any reference to confirm my assumption. What does this statement mean and how does typescript export type work?... More on community.testmuai.com
🌐 community.testmuai.com
0
November 6, 2024
TypeScript export imported interface - Stack Overflow
I use AMD modules and I want to hide a complex interface behind one file that loads several other files and chooses what to expose and how. It works, I use this solution but it feels kinda ugly, mo... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/typescript › to export or not to export types (implicit vs explicit)
r/typescript on Reddit: To export or not to export types (implicit vs explicit)
November 3, 2023 -

Hello,

I've been putting types that can be used all over my app on types.ts files. The interfaces and types in these files don't get exported and this way VSCode / Typescript somehow knows that they exist globally. This avoids having to import them whenever they are used as normally I already have quite a few other imports for actual code. That's the main reason I've been using to not having to explicitly export/import those types.

However recently I came up with two other thoughts:

  1. When creating a library, it seems the way to go is to export types. This way you can select which types are exposed (or not) and you avoid "namespacing". To avoid name conflicts when not explicitly exporting types, I normally use something like PossiblyLongNameProps or PossiblyLongNameState. These names can get long and repetitive (the PossiblyLongName part).

  2. These long names for "namespacing" got me thinking that I should probably be exporting types, at least in some cases. So it's sort of a conflict between "I don't want to be using long names for my interfaces/types" vs "I don't want to explicitly import every single type I use".

Does that make sense? What do you think? What's your approach to this?

Thank you!

🌐
Medium
medium.com › @robinviktorsson › typescript-and-es-modules-best-practices-for-imports-and-exports-9ce200e75a88
TypeScript and ES Modules: Best Practices for Imports and Exports | by Robin Viktorsson | Medium
March 10, 2025 - TypeScript introduces a helpful feature for type-only imports and exports. If you’re exporting a type or interface, use the export type syntax.
🌐
TypeScript
typescriptlang.org › docs › handbook › modules › reference.html
TypeScript: Documentation - Modules - Reference
This syntax was used over its JavaScript counterparts since variable declarations and property assignments could not refer to TypeScript types, whereas special TypeScript syntax could: ... module.exports = Options; // Error: 'Options' only refers to a type, but is being used as a value here.
🌐
GitHub
github.com › microsoft › TypeScript › issues › 37238
[request] allow `export type * from` · Issue #37238 · microsoft/TypeScript
March 6, 2020 - Search Terms export type Suggestion TS1383: Only named exports may use 'export type'. allow export type * from Use Cases https://github.com/bluelovers/ws-ts-type/blob/master/packages/ts-type/index.ts export type * from './lib'; export ty...
Author   bluelovers
🌐
GitHub
github.com › microsoft › TypeScript › issues › 48508
`export type * from 'somewhere'` · Issue #48508 · microsoft/TypeScript
April 1, 2022 - export {one, two, three} from 'foo' // re-export certain runtime things. export type * from 'foo' // re-export all types.
Author   trusktr
Find elsewhere
🌐
TestMu AI Community
community.testmuai.com › ask a question
What does export type mean in TypeScript? - Ask a Question - TestMu AI Community
November 6, 2024 - What does export type mean in TypeScript? I came across the following syntax in TypeScript: export type feline = typeof cat; As far as I know, type is not a built-in basic type, nor is it an interface or class. It see…
🌐
TypeScript ESlint
typescript-eslint.io › rules › consistent-type-exports
consistent-type-exports | typescript-eslint
... This rule requires type information to run, which comes with performance tradeoffs. TypeScript allows specifying a type keyword on exports to indicate that the export exists only in the type system, not at runtime.
🌐
TypeScript
typescriptlang.org › docs › handbook › modules.html
TypeScript: Documentation - Modules
April 11, 2023 - Conversely, a file without any ... in the global scope (and therefore to modules as well). Any declaration (such as a variable, function, class, type alias, or interface) can be exported by adding the export keyword....
🌐
Bobby Hadz
bobbyhadz.com › blog › typescript-export-interface
How to export Interfaces and Types in TypeScript | bobbyhadz
February 28, 2024 - Use a named export to export an interface in TypeScript, e.g. `export interface Person{}`.
🌐
TypeScript
typescriptlang.org › docs › handbook › declaration-files › templates › module-d-ts.html
TypeScript: Documentation - Modules .d.ts
A module using CommonJS patterns uses module.exports to describe the exported values. For example, here is a module which exports a function and a numerical constant: ... The TypeScript playground can show you the .d.ts equivalent for JavaScript code.
🌐
Total TypeScript
totaltypescript.com › tips › turn-a-module-into-a-type
Turn a module into a type | Total TypeScript
export type Action = "ADD_TODO" | "REMOVE_TODO" | "EDIT_TODO" This is a common pattern in older Redux applications. Now, we've actually got a constants.ts file which has all of the elements of the union. They're even inferred by TypeScript.
Published   May 30, 2023
Top answer
1 of 3
321

There is an export import syntax for legacy modules, and a standard export format for modern ES6 modules:

// export the default export of a legacy (`export =`) module
export import MessageBase = require('./message-base');

// export the default export of a modern (`export default`) module
export { default as MessageBase } from './message-base';

// when '--isolatedModules' flag is provided it requires using 'export type'.
export type { default as MessageBase } from './message-base';

// export an interface from a legacy module
import Types = require('./message-types');
export type IMessage = Types.IMessage;

// export an interface from a modern module
export { IMessage } from './message-types';
2 of 3
90

Some more examples besides #c-snover's answer from here. You can put them together.

import 'jquery';                        // import a module without any import bindings
import $ from 'jquery';                 // import the default export of a module
import { $ } from 'jquery';             // import a named export of a module
import { $ as jQuery } from 'jquery';   // import a named export to a different name
import * as crypto from 'crypto';       // import an entire module instance object

export var x = 42;                      // export a named variable
export function foo() {};               // export a named function

export default 42;                      // export the default export
export default function foo() {};       // export the default export as a function

export { encrypt };                     // export an existing variable
export { decrypt as dec };              // export a variable as a new name
export { encrypt as en } from 'crypto'; // export an export from another module
export * from 'crypto';                 // export all exports from another module
                                        // (except the default export)
🌐
Reddit
reddit.com › r/typescript › how to export type definitions for third-party package?
r/typescript on Reddit: How to export type definitions for third-party package?
February 18, 2022 -

I'm writing a package that uses a third party package that doesn't include its own typescript definitions. I've written my own .d.ts definitions for this third party package using a format like the following:

declare module 'third-party-package' {
	class ThirdParty {
		// methods and whatnot here...
	}

	namespace ThirdParty {
		type Options = {
			// various options...
		}

		// and a few more helper types here...
	}

	export default ThirdParty
}

The problem is, my package can accept a callback that will pass this third party class to it, so I would also like to export my definition for it as well. That way a user could do something like this:

import MyClass, { ThirdParty } from 'my-package'

const x = new MyClass({ callback: (tp: ThirdParty) => {
	// do something with the third party class here...
}})

Note that I do not need to export the actual third party class, just types for it. I know how to export my types, and I can define the types for this third party package internally, but I cannot seem to figure out how to do both without basically defining these types twice (one to export and one to use for the package internally). Of course I don't want to do it like this.

Anyone have any idea how to go about defining this third party package in one place and exporting this definition for consumers of my package to use? Thanks!

Top answer
1 of 5
2
Are the third party types in a @types package? If so, add that as a non-dev dependency and export the type directly from there.
2 of 5
1
Ok, for anyone coming across this in the future, I think I've figured out a working solution, though it's a bit roundabout. Feel free to let me know if anyone figures out a simpler way to do it. The first step was to move my definition for the third party package into its own local, "internal" package. So I added a subfolder to my project with it's own basic package.json file that pointed to my definition. And I made sure to name this internal package like "@types/third-party-package-name". Here's what this subfolder package.json looked like (index.d.ts is my definition): { "name": "@types/third-party-package-name", "version": "1.0.0", "main": "", "types": "index.d.ts", "private": true } This allowed me to add a "local" dependency to my project for this sub-package: npm i ./definition-subfolder This adds a dependency to my root package.json that looks like: "dependencies": { "@types/third-party-package-name": "file:definition-subfolder", ... }, So now my project is using my custom definition, but it appears as if it's a "normal" @types definition. This, I believe, associates the definition to my third party package without having to define it as an ambient module , allowing me to define it using more traditional exports without the declare module '' {} wrapper: declare class ThirdParty { // methods and whatnot here... } declare namespace ThirdParty { type Options = { // various options... } // and a few more helper types here... } export default ThirdParty Now this definition is automatically used internally when I import the third party package (due to it being an @types package): import ThirdParty from 'third-party-package-name' And I can successfully export it in my main index.ts file by using the original third party package name. In order to export just the type, I have to specify export type: export type { default as ThirdParty } from 'third-party-package-name'
🌐
Scaler
scaler.com › home › topics › typescript › importing and exporting with static types
Importing and Exporting with Static Types - Scaler Topics
May 4, 2023 - A module can be declared by using the export keyword. The syntax for the declaration of the module is given as: Any kind of declaration like variable, function, interface, or type alias can be exported by adding the export keyword.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › typescript tutorial › typescript export function
TypeScript Export Function | Example of TypeScript Export Function
April 11, 2023 - As now we already know that export keyword is used to export the classes, interface, functions, and type in TypeScript and made them available to reuse the component by importing them inside any other module by using the import statement at ...
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
TypeScript ESlint
typescript-eslint.io › blog › consistent-type-imports-and-exports-why-and-how
Consistent Type Imports and Exports: Why and How | typescript-eslint
February 24, 2023 - In conjunction with @typescript-eslint/consistent-type-imports, eslint-plugin-import's rules can enforce your imports are always properly qualified and are written in a standard, predictable style (eg always top-level type qualifier or always inline type-qualifier). TypeScript 5.0 additionally adds a new --verbatimModuleSyntax compiler option. verbatimModuleSyntax simplifies TypeScript's logic around whether to preserve imports. From the TypeScript release notes: ...any imports or exports without a type modifier are left around.