mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-10 01:15:00 +08:00
Summary: It was hard to type the resolution main algo, I had to put type annotations explicitely everywhere, otherwise Flow would get in some kind of loop and do weird errors. I think it's because the algo is recursive and Flow tries to infer types too deeply because of the generics. Anyway, apart from that it's good to get this extra type security in the few other places. We require Node v4 minimum, that according to the internets supports the `class` syntax without transform, and I verified that inheriting from `Map` actually works as expected. Reviewed By: davidaurelio Differential Revision: D5078023 fbshipit-source-id: 05dfc4acf5b07cdda8a7b36ec9cba216d1810643
25 lines
629 B
JavaScript
25 lines
629 B
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
jest.disableAutomock();
|
|
|
|
const MapWithDefaults = require('../MapWithDefaults');
|
|
|
|
describe('MapWithDefaults', function() {
|
|
it('works', () => {
|
|
const map = new MapWithDefaults(() => ['bar']);
|
|
map.get('foo').push('baz');
|
|
expect(map.get('foo')).toEqual(['bar', 'baz']);
|
|
});
|
|
});
|