Skip to content

Commit

Permalink
Add new example for TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagodp committed Nov 24, 2024
1 parent e398e1f commit 4deba7e
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/typescript-pkg/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example.js
9 changes: 9 additions & 0 deletions examples/typescript-pkg/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// pnpm exec tsc && node example.js

import countryToCurrency, { Currencies, Countries } from "country-to-currency";

const currency: Currencies = 'BRL';
const country: Countries = 'BR';

console.log( countryToCurrency[ 'AD' ] );
console.log( currency, country );
14 changes: 14 additions & 0 deletions examples/typescript-pkg/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "example-typescript-pkg",
"type": "module",
"scripts": {
"start": "tsc && node example.js"
},
"devDependencies": {
"@types/node": "^22.9.3",
"typescript": "^5.7.2"
},
"dependencies": {
"country-to-currency": "^2.0.1"
}
}
48 changes: 48 additions & 0 deletions examples/typescript-pkg/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions examples/typescript-pkg/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"module": "ES2015", /* Specify what module code is generated. */
"moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This library exports a default object that maps country codes to currency codes.
[Available formats]() include [UMD](https://github.com/umdjs/umd) (therefore [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) and [CommonJS](http://wiki.commonjs.org/wiki/CommonJS)) and
[ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules).

👉 Examples available in the folder `examples`.
👉 Examples available in the folder [examples](https://github.com/thiagodp/country-to-currency/tree/master/examples).

### TypeScript

Expand Down

0 comments on commit 4deba7e

Please sign in to comment.