Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail TypeScript import #106

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
}

if (typeof module !== 'undefined' && module.exports) {
classNames.default = classNames;
module.exports = classNames;
} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
// register as 'classnames', consistent with npm package name
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"scripts": {
"benchmarks": "node ./benchmarks/run",
"test": "mocha tests/*.js"
"test": "mocha tests/*.js && mocha --compilers ts:ts-node/register tests/*.ts"
},
"keywords": [
"react",
Expand All @@ -23,7 +23,12 @@
"utility"
],
"devDependencies": {
"@types/mocha": "^2.2.33",
"@types/node": "0.0.2",
"assert": "^1.4.1",
"benchmark": "^1.0.0",
"mocha": "^2.1.0"
"mocha": "^2.1.0",
"ts-node": "^1.7.2",
"typescript": "^2.1.4"
}
}
10 changes: 10 additions & 0 deletions tests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference path="../node_modules/@types/mocha/index.d.ts" />

import * as assert from 'assert';
import classNames from '../';

describe('classNames module', function () {
it('exports a function as default', function () {
assert.equal(typeof classNames, 'function');
});
});
17 changes: 17 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"module": "commonjs",
"target": "es5"
},
"include": [
"tests/index.ts"
],
"exclude": [
"node_modules"
],
"typeAcquisition": {
"enable": false
}
}