Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e1a9649

Browse filesBrowse files
authored
Make docs not use class terminology (immutable-js#1596)
Since ES6 formally defined `class`, Immutable.js docs have been misleading since they produce factory functions instead of class constructors. This changes "class" to "type" in the docs and ads explicit text explaining the use of `new` for each factory function. Fixes immutable-js#1421
1 parent 962cca7 commit e1a9649
Copy full SHA for e1a9649

File tree

2 files changed

+51
-1
lines changed
Filter options

2 files changed

+51
-1
lines changed

‎pages/src/docs/src/Defs.js

Copy file name to clipboardExpand all lines: pages/src/docs/src/Defs.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var InterfaceDef = React.createClass({
1818
var def = this.props.def;
1919
return (
2020
<span className="t interfaceDef">
21-
<span className="t keyword">class </span>
21+
<span className="t keyword">type </span>
2222
<span className="t typeName">{name}</span>
2323
{def.typeParams && [
2424
'<',

‎type-definitions/Immutable.d.ts

Copy file name to clipboardExpand all lines: type-definitions/Immutable.d.ts
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ declare module Immutable {
153153
* Create a new immutable List containing the values of the provided
154154
* collection-like.
155155
*
156+
* Note: `List` is a factory function and not a class, and does not use the
157+
* `new` keyword during construction.
158+
*
156159
* <!-- runkit:activate -->
157160
* ```js
158161
* const { List, Set } = require('immutable')
@@ -725,6 +728,9 @@ declare module Immutable {
725728
* Created with the same key value pairs as the provided Collection.Keyed or
726729
* JavaScript Object or expects a Collection of [K, V] tuple entries.
727730
*
731+
* Note: `Map` is a factory function and not a class, and does not use the
732+
* `new` keyword during construction.
733+
*
728734
* <!-- runkit:activate -->
729735
* ```js
730736
* const { Map } = require('immutable')
@@ -1409,6 +1415,8 @@ declare module Immutable {
14091415
* let newOrderedMap = OrderedMap({key: "value"})
14101416
* let newOrderedMap = OrderedMap([["key", "value"]])
14111417
*
1418+
* Note: `OrderedMap` is a factory function and not a class, and does not use
1419+
* the `new` keyword during construction.
14121420
*/
14131421
export function OrderedMap<K, V>(collection: Iterable<[K, V]>): OrderedMap<K, V>;
14141422
export function OrderedMap<T>(collection: Iterable<Iterable<T>>): OrderedMap<T, T>;
@@ -1600,6 +1608,9 @@ declare module Immutable {
16001608
/**
16011609
* Create a new immutable Set containing the values of the provided
16021610
* collection-like.
1611+
*
1612+
* Note: `Set` is a factory function and not a class, and does not use the
1613+
* `new` keyword during construction.
16031614
*/
16041615
export function Set(): Set<any>;
16051616
export function Set<T>(): Set<T>;
@@ -1781,6 +1792,9 @@ declare module Immutable {
17811792
/**
17821793
* Create a new immutable OrderedSet containing the values of the provided
17831794
* collection-like.
1795+
*
1796+
* Note: `OrderedSet` is a factory function and not a class, and does not use
1797+
* the `new` keyword during construction.
17841798
*/
17851799
export function OrderedSet(): OrderedSet<any>;
17861800
export function OrderedSet<T>(): OrderedSet<T>;
@@ -1938,6 +1952,9 @@ declare module Immutable {
19381952
*
19391953
* The iteration order of the provided collection is preserved in the
19401954
* resulting `Stack`.
1955+
*
1956+
* Note: `Stack` is a factory function and not a class, and does not use the
1957+
* `new` keyword during construction.
19411958
*/
19421959
export function Stack(): Stack<any>;
19431960
export function Stack<T>(): Stack<T>;
@@ -2157,6 +2174,9 @@ declare module Immutable {
21572174
* (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to
21582175
* infinity. When `start` is equal to `end`, returns empty range.
21592176
*
2177+
* Note: `Range` is a factory function and not a class, and does not use the
2178+
* `new` keyword during construction.
2179+
*
21602180
* ```js
21612181
* const { Range } = require('immutable')
21622182
* Range() // [ 0, 1, 2, 3, ... ]
@@ -2174,6 +2194,9 @@ declare module Immutable {
21742194
* Returns a Seq.Indexed of `value` repeated `times` times. When `times` is
21752195
* not defined, returns an infinite `Seq` of `value`.
21762196
*
2197+
* Note: `Repeat` is a factory function and not a class, and does not use the
2198+
* `new` keyword during construction.
2199+
*
21772200
* ```js
21782201
* const { Repeat } = require('immutable')
21792202
* Repeat('foo') // [ 'foo', 'foo', 'foo', ... ]
@@ -2433,6 +2456,9 @@ declare module Immutable {
24332456
* Record Factory, which is a function that creates Record instances.
24342457
*
24352458
* See above for examples of using `Record()`.
2459+
*
2460+
* Note: `Record` is a factory function and not a class, and does not use the
2461+
* `new` keyword during construction.
24362462
*/
24372463
export function Record<TProps>(defaultValues: TProps, name?: string): Record.Factory<TProps>;
24382464

@@ -2659,6 +2685,9 @@ declare module Immutable {
26592685
/**
26602686
* Always returns a Seq.Keyed, if input is not keyed, expects an
26612687
* collection of [K, V] tuples.
2688+
*
2689+
* Note: `Seq.Keyed` is a conversion function and not a class, and does not
2690+
* use the `new` keyword during construction.
26622691
*/
26632692
export function Keyed<K, V>(collection: Iterable<[K, V]>): Seq.Keyed<K, V>;
26642693
export function Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
@@ -2780,6 +2809,9 @@ declare module Immutable {
27802809
/**
27812810
* Always returns Seq.Indexed, discarding associated keys and
27822811
* supplying incrementing indices.
2812+
*
2813+
* Note: `Seq.Indexed` is a conversion function and not a class, and does
2814+
* not use the `new` keyword during construction.
27832815
*/
27842816
export function Indexed(): Seq.Indexed<any>;
27852817
export function Indexed<T>(): Seq.Indexed<T>;
@@ -2929,6 +2961,9 @@ declare module Immutable {
29292961

29302962
/**
29312963
* Always returns a Seq.Set, discarding associated indices or keys.
2964+
*
2965+
* Note: `Seq.Set` is a conversion function and not a class, and does not
2966+
* use the `new` keyword during construction.
29322967
*/
29332968
export function Set(): Seq.Set<any>;
29342969
export function Set<T>(): Seq.Set<T>;
@@ -3024,6 +3059,9 @@ declare module Immutable {
30243059
* which is usually not what you want. You should turn your Iterator Object into
30253060
* an iterable object by defining a Symbol.iterator (or @@iterator) method which
30263061
* returns `this`.
3062+
*
3063+
* Note: `Seq` is a conversion function and not a class, and does not use the
3064+
* `new` keyword during construction.
30273065
*/
30283066
export function Seq<S extends Seq<any, any>>(seq: S): S;
30293067
export function Seq<K, V>(collection: Collection.Keyed<K, V>): Seq.Keyed<K, V>;
@@ -3200,6 +3238,9 @@ declare module Immutable {
32003238
*
32013239
* Similar to `Collection()`, however it expects collection-likes of [K, V]
32023240
* tuples if not constructed from a Collection.Keyed or JS Object.
3241+
*
3242+
* Note: `Collection.Keyed` is a conversion function and not a class, and
3243+
* does not use the `new` keyword during construction.
32033244
*/
32043245
export function Keyed<K, V>(collection: Iterable<[K, V]>): Collection.Keyed<K, V>;
32053246
export function Keyed<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>;
@@ -3358,6 +3399,9 @@ declare module Immutable {
33583399

33593400
/**
33603401
* Creates a new Collection.Indexed.
3402+
*
3403+
* Note: `Collection.Indexed` is a conversion function and not a class, and
3404+
* does not use the `new` keyword during construction.
33613405
*/
33623406
export function Indexed<T>(collection: Iterable<T>): Collection.Indexed<T>;
33633407

@@ -3648,6 +3692,9 @@ declare module Immutable {
36483692

36493693
/**
36503694
* Similar to `Collection()`, but always returns a Collection.Set.
3695+
*
3696+
* Note: `Collection.Set` is a factory function and not a class, and does
3697+
* not use the `new` keyword during construction.
36513698
*/
36523699
export function Set<T>(collection: Iterable<T>): Collection.Set<T>;
36533700

@@ -3746,6 +3793,9 @@ declare module Immutable {
37463793
* which is usually not what you want. You should turn your Iterator Object into
37473794
* an iterable object by defining a Symbol.iterator (or @@iterator) method which
37483795
* returns `this`.
3796+
*
3797+
* Note: `Collection` is a conversion function and not a class, and does not
3798+
* use the `new` keyword during construction.
37493799
*/
37503800
export function Collection<I extends Collection<any, any>>(collection: I): I;
37513801
export function Collection<T>(collection: Iterable<T>): Collection.Indexed<T>;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.