From 240e3a6c8907903c5fb02cf4d95d56a53829e56e Mon Sep 17 00:00:00 2001 From: Rob Wormald Date: Thu, 26 May 2016 18:18:11 -0700 Subject: [PATCH 1/4] fix(types): use default syntax for typedef this will enable projects consuming symbol-observable from TS (eg, RxJS) to use ```typescript import $$observable from 'symbol-observable' ``` rather than ```typescript import * as $$observable from 'symbol-observable' ``` This might? require downstream changes on RxJS but its more correct methinks. --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index e5dd040..6816a1d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,2 +1,2 @@ declare const observableSymbol: symbol; -export = observableSymbol; \ No newline at end of file +export default observableSymbol; From 4fd9e0f067eece2abfb7155893a9f4a3f67838cd Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Sat, 28 May 2016 13:08:51 -0700 Subject: [PATCH 2/4] test(typescript): add TypeScript test to ensure it imports and compiles okay --- .gitignore | 1 + package.json | 4 +++- ts-test/test.ts | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 ts-test/test.ts diff --git a/.gitignore b/.gitignore index 491fc35..92b258f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules lib +ts-test/test.js diff --git a/package.json b/package.json index 37f0f24..c43272c 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "node": ">=0.10.0" }, "scripts": { + "test": "mocha && tsc ./ts-test/test.ts && node ./ts-test/test.js" "build": "babel es --out-dir lib", "test": "npm run build && mocha", "prepublish": "npm test" @@ -39,6 +40,7 @@ "babel-plugin-add-module-exports": "^0.2.1", "babel-preset-es2015": "^6.9.0", "chai": "^3.5.0", - "mocha": "^2.4.5" + "mocha": "^2.4.5", + "typescript": "^1.8.10" } } diff --git a/ts-test/test.ts b/ts-test/test.ts new file mode 100644 index 0000000..69e8c4b --- /dev/null +++ b/ts-test/test.ts @@ -0,0 +1,9 @@ +import $$symbolObservable from '../'; + +console.log('***********************'); +console.log('RUNNING TYPESCRIPT TEST'); +console.log('***********************'); + +if (typeof $$symbolObservable !== 'symbol' && $$symbolObservable !== '@@observable') { + throw new Error('Sorry, $symbolObservable is ' + JSON.stringify($$symbolObservable)); +} From ea5022ba2ea20e57b86e146cb09f112abbf85704 Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Sat, 28 May 2016 13:50:38 -0700 Subject: [PATCH 3/4] refactor(conflicts): resolving merge issues --- es/index.js | 7 +++++-- package.json | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/es/index.js b/es/index.js index dacce17..548ba11 100644 --- a/es/index.js +++ b/es/index.js @@ -1,11 +1,14 @@ /* global window */ import ponyfill from './ponyfill'; -let root = this; +var root = this; if (typeof global !== 'undefined') { root = global; } else if (typeof window !== 'undefined') { root = window; } -export default ponyfill(root); +var result = ponyfill(root); +// being explicit +result['default'] = result; +export default result; diff --git a/package.json b/package.json index c43272c..bc6f962 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,8 @@ "node": ">=0.10.0" }, "scripts": { - "test": "mocha && tsc ./ts-test/test.ts && node ./ts-test/test.js" + "test": "npm run build && mocha && tsc ./ts-test/test.ts && node ./ts-test/test.js", "build": "babel es --out-dir lib", - "test": "npm run build && mocha", "prepublish": "npm test" }, "files": [ From c0b894e4199fc051f718bfeadd1abe53b539c00b Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Mon, 13 Jun 2016 14:49:22 -0700 Subject: [PATCH 4/4] fix(TypeScript): exported ponyfill now works with TypeScript BREAKING CHANGE: CJS users will now have to --- .babelrc | 3 +-- es/index.js | 2 -- package.json | 1 - test/index.js | 2 +- test/ponyfill.js | 2 +- ts-test/test.ts | 7 ++++--- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.babelrc b/.babelrc index efbacd7..c13c5f6 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,3 @@ { - "presets": ["es2015"], - "plugins": ["add-module-exports"], + "presets": ["es2015"] } diff --git a/es/index.js b/es/index.js index 548ba11..5dcb9e9 100644 --- a/es/index.js +++ b/es/index.js @@ -9,6 +9,4 @@ if (typeof global !== 'undefined') { } var result = ponyfill(root); -// being explicit -result['default'] = result; export default result; diff --git a/package.json b/package.json index bc6f962..a375c4e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ ], "devDependencies": { "babel-cli": "^6.9.0", - "babel-plugin-add-module-exports": "^0.2.1", "babel-preset-es2015": "^6.9.0", "chai": "^3.5.0", "mocha": "^2.4.5", diff --git a/test/index.js b/test/index.js index 187e538..6551c3e 100644 --- a/test/index.js +++ b/test/index.js @@ -1,6 +1,6 @@ /* global describe, it */ var expect = require('chai').expect; -var $$observable = require('../'); +var $$observable = require('../').default; describe('integration test', function () { if (typeof Symbol === 'function') { diff --git a/test/ponyfill.js b/test/ponyfill.js index 617e37c..ae08fb5 100644 --- a/test/ponyfill.js +++ b/test/ponyfill.js @@ -1,6 +1,6 @@ /* global describe, it */ var expect = require('chai').expect; -var ponyfill = require('../lib/ponyfill'); +var ponyfill = require('../lib/ponyfill').default; describe('ponyfill unit tests', function () { describe('when Symbol does NOT exist as a function', function () { diff --git a/ts-test/test.ts b/ts-test/test.ts index 69e8c4b..fdab634 100644 --- a/ts-test/test.ts +++ b/ts-test/test.ts @@ -1,9 +1,10 @@ import $$symbolObservable from '../'; -console.log('***********************'); -console.log('RUNNING TYPESCRIPT TEST'); -console.log('***********************'); +console.log('RUNNING TYPESCRIPT TEST...'); if (typeof $$symbolObservable !== 'symbol' && $$symbolObservable !== '@@observable') { + console.log('FAIL'); throw new Error('Sorry, $symbolObservable is ' + JSON.stringify($$symbolObservable)); } + +console.log('PASS');