https://github.com/deeper-x/custom-declaration
Typescript: simple demo with custom declaration file, included with reference path
https://github.com/deeper-x/custom-declaration
custom-declaration-file declaration-files npm tsconfig typescript
Last synced: 2 months ago
JSON representation
Typescript: simple demo with custom declaration file, included with reference path
- Host: GitHub
- URL: https://github.com/deeper-x/custom-declaration
- Owner: deeper-x
- Created: 2019-01-02T11:22:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-30T04:11:44.000Z (about 3 years ago)
- Last Synced: 2025-03-27T03:27:40.165Z (about 1 year ago)
- Topics: custom-declaration-file, declaration-files, npm, tsconfig, typescript
- Language: JavaScript
- Homepage:
- Size: 140 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Typescript - Declaration file for a custom module
With this simple example, we show how to define and set up a type definition for a custom Javascript library, in a Typescript module.
We write and publish on npm a test module, a "reverse with sharps" library: given an input string, it returns the reversed version with some sharps around.
Example:
```javascript
console.log(reverseWithSharps("ALBERTO"));
// result: ## OTREBLA ##
```
Then we use it in a TS file, simply defining a declaration file, requiring an input string as a parameter, returning a string as a result:
```javascript
///
import * as myModule from 'reverse-with-sharps';
console.log(myModule.reverseWithSharps("ALBERTO"));
// result: ## OTREBLA ##
```