Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ jobs:
rm example.js
- name: Verify TypeScript can consume the package
run: |
echo "import osrmTextInstructions = require('./index'); const compiler = osrmTextInstructions('v5'); console.log('TypeScript import works!');" > test-import.ts
echo "import osrmTextInstructions from './index'; const compiler = osrmTextInstructions('v5'); console.log('TypeScript import works!');" > test-import.ts
npx tsc --noEmit test-import.ts
rm test-import.ts
rm test-import.ts
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
transifex.auth
dist
example.js
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ response.legs.forEach(function(leg) {
### TypeScript Usage

```typescript
import osrmTextInstructions = require('osrm-text-instructions');
import osrmTextInstructions from 'osrm-text-instructions';

const compiler = osrmTextInstructions('v5');

Expand Down
20 changes: 14 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const js = require('@eslint/js');

module.exports = [
{
ignores: ['node_modules/**', 'eslint.config.js'],
ignores: ['node_modules/**', 'dist/**', 'example.js']
},
{
files: ['**/*.js'],
Expand All @@ -19,8 +19,8 @@ module.exports = [
global: 'readonly',
module: 'writable',
require: 'readonly',
fetch: 'readonly',
},
fetch: 'readonly'
}
},
rules: {
...js.configs.recommended.rules,
Expand All @@ -32,12 +32,17 @@ module.exports = [
'arrow-spacing': 'error',
'block-scoped-var': 'error',
'block-spacing': ['error', 'always'],
'brace-style': ['error', '1tbs', {allowSingleLine: true}],
'brace-style': ['error', '1tbs', {
allowSingleLine: true
}],
'callback-return': 'error',
camelcase: 'error',
'class-methods-use-this': 'error',
'comma-dangle': 'error',
'comma-spacing': ['error', {after: true, before: false}],
'comma-spacing': ['error', {
after: true,
before: false
}],
'comma-style': 'error',
complexity: 'off',
'computed-property-spacing': ['error', 'never'],
Expand All @@ -60,7 +65,10 @@ module.exports = [
'init-declarations': 'off',
'jsx-quotes': 'error',
'key-spacing': 'error',
'keyword-spacing': ['error', {after: true, before: true}],
'keyword-spacing': ['error', {
after: true,
before: true
}],
'linebreak-style': ['error', 'unix'],
'lines-around-comment': 'error',
'max-depth': 'error',
Expand Down
2 changes: 1 addition & 1 deletion example.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Example usage of osrm-text-instructions with TypeScript

import osrmTextInstructions = require('./index');
import osrmTextInstructions from './index.js';

// Initialize the compiler for OSRM v5
const compiler = osrmTextInstructions('v5');
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
"eslint": "^10.2.0",
"mkdirp": "^3.0.1",
"tape": "^5.9.0",
"typescript": "^5.0.0"
"typescript": "^6.0.3"
},
"scripts": {
"lint": "eslint *.js test/*.js scripts/*.js",
"lint": "eslint eslint.config.js index.js languages.js test/*.js scripts/*.js",
"pretest": "npm run lint",
"test": "tape test/*_test.js",
"transifex": "node scripts/transifex.js",
"type-check": "tsc --noEmit example.ts",
"validate-types": "tsc --noEmit index.d.ts"
"type-check": "tsc --noEmit --project tsconfig.example.json",
"validate-types": "tsc --noEmit --project tsconfig.types.json"
}
}
15 changes: 3 additions & 12 deletions tsconfig.json → tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@
"strictFunctionTypes": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"*.ts",
"*.d.ts"
],
"exclude": [
"node_modules",
"dist",
"test"
]
}
}
}
6 changes: 6 additions & 0 deletions tsconfig.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.base.json",
"files": [
"example.ts"
]
}
6 changes: 6 additions & 0 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.base.json",
"files": [
"index.d.ts"
]
}
Loading