Original test passes!
So I'm done, right?
This commit is contained in:
parent
7f8839d115
commit
ea1b78db15
|
@ -0,0 +1,64 @@
|
|||
=== tests/cases/conformance/salsa/genericPropertiesOfConstructorFunctions.js ===
|
||||
/**
|
||||
* @template {string} K
|
||||
* @template V
|
||||
* @param {string} ik
|
||||
* @param {V} iv
|
||||
*/
|
||||
function Multimap(ik, iv) {
|
||||
>Multimap : Symbol(Multimap, Decl(genericPropertiesOfConstructorFunctions.js, 0, 0))
|
||||
>ik : Symbol(ik, Decl(genericPropertiesOfConstructorFunctions.js, 6, 18))
|
||||
>iv : Symbol(iv, Decl(genericPropertiesOfConstructorFunctions.js, 6, 21))
|
||||
|
||||
/** @type {{ [s: string]: V }} */
|
||||
this._map = {};
|
||||
>_map : Symbol(Multimap._map, Decl(genericPropertiesOfConstructorFunctions.js, 6, 27))
|
||||
|
||||
// without type annotation
|
||||
this._map2 = { [ik]: iv };
|
||||
>_map2 : Symbol(Multimap._map2, Decl(genericPropertiesOfConstructorFunctions.js, 8, 19))
|
||||
>[ik] : Symbol([ik], Decl(genericPropertiesOfConstructorFunctions.js, 10, 18))
|
||||
>ik : Symbol(ik, Decl(genericPropertiesOfConstructorFunctions.js, 6, 18))
|
||||
>iv : Symbol(iv, Decl(genericPropertiesOfConstructorFunctions.js, 6, 21))
|
||||
|
||||
};
|
||||
|
||||
/** @type {Multimap<"a" | "b", number>} with type annotation */
|
||||
const map = new Multimap("a", 1);
|
||||
>map : Symbol(map, Decl(genericPropertiesOfConstructorFunctions.js, 14, 5))
|
||||
>Multimap : Symbol(Multimap, Decl(genericPropertiesOfConstructorFunctions.js, 0, 0))
|
||||
|
||||
// without type annotation
|
||||
const map2 = new Multimap("m", 2);
|
||||
>map2 : Symbol(map2, Decl(genericPropertiesOfConstructorFunctions.js, 16, 5))
|
||||
>Multimap : Symbol(Multimap, Decl(genericPropertiesOfConstructorFunctions.js, 0, 0))
|
||||
|
||||
/** @type {number} */
|
||||
var n = map._map['hi']
|
||||
>n : Symbol(n, Decl(genericPropertiesOfConstructorFunctions.js, 19, 3), Decl(genericPropertiesOfConstructorFunctions.js, 21, 3), Decl(genericPropertiesOfConstructorFunctions.js, 23, 3), Decl(genericPropertiesOfConstructorFunctions.js, 25, 3))
|
||||
>map._map : Symbol(Multimap._map, Decl(genericPropertiesOfConstructorFunctions.js, 6, 27))
|
||||
>map : Symbol(map, Decl(genericPropertiesOfConstructorFunctions.js, 14, 5))
|
||||
>_map : Symbol(Multimap._map, Decl(genericPropertiesOfConstructorFunctions.js, 6, 27))
|
||||
|
||||
/** @type {number} */
|
||||
var n = map._map2['hi']
|
||||
>n : Symbol(n, Decl(genericPropertiesOfConstructorFunctions.js, 19, 3), Decl(genericPropertiesOfConstructorFunctions.js, 21, 3), Decl(genericPropertiesOfConstructorFunctions.js, 23, 3), Decl(genericPropertiesOfConstructorFunctions.js, 25, 3))
|
||||
>map._map2 : Symbol(Multimap._map2, Decl(genericPropertiesOfConstructorFunctions.js, 8, 19))
|
||||
>map : Symbol(map, Decl(genericPropertiesOfConstructorFunctions.js, 14, 5))
|
||||
>_map2 : Symbol(Multimap._map2, Decl(genericPropertiesOfConstructorFunctions.js, 8, 19))
|
||||
|
||||
/** @type {number} */
|
||||
var n = map2._map['hi']
|
||||
>n : Symbol(n, Decl(genericPropertiesOfConstructorFunctions.js, 19, 3), Decl(genericPropertiesOfConstructorFunctions.js, 21, 3), Decl(genericPropertiesOfConstructorFunctions.js, 23, 3), Decl(genericPropertiesOfConstructorFunctions.js, 25, 3))
|
||||
>map2._map : Symbol(Multimap._map, Decl(genericPropertiesOfConstructorFunctions.js, 6, 27))
|
||||
>map2 : Symbol(map2, Decl(genericPropertiesOfConstructorFunctions.js, 16, 5))
|
||||
>_map : Symbol(Multimap._map, Decl(genericPropertiesOfConstructorFunctions.js, 6, 27))
|
||||
|
||||
/** @type {number} */
|
||||
var n = map._map2['hi']
|
||||
>n : Symbol(n, Decl(genericPropertiesOfConstructorFunctions.js, 19, 3), Decl(genericPropertiesOfConstructorFunctions.js, 21, 3), Decl(genericPropertiesOfConstructorFunctions.js, 23, 3), Decl(genericPropertiesOfConstructorFunctions.js, 25, 3))
|
||||
>map._map2 : Symbol(Multimap._map2, Decl(genericPropertiesOfConstructorFunctions.js, 8, 19))
|
||||
>map : Symbol(map, Decl(genericPropertiesOfConstructorFunctions.js, 14, 5))
|
||||
>_map2 : Symbol(Multimap._map2, Decl(genericPropertiesOfConstructorFunctions.js, 8, 19))
|
||||
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
=== tests/cases/conformance/salsa/genericPropertiesOfConstructorFunctions.js ===
|
||||
/**
|
||||
* @template {string} K
|
||||
* @template V
|
||||
* @param {string} ik
|
||||
* @param {V} iv
|
||||
*/
|
||||
function Multimap(ik, iv) {
|
||||
>Multimap : typeof Multimap
|
||||
>ik : string
|
||||
>iv : V
|
||||
|
||||
/** @type {{ [s: string]: V }} */
|
||||
this._map = {};
|
||||
>this._map = {} : {}
|
||||
>this._map : any
|
||||
>this : any
|
||||
>_map : any
|
||||
>{} : {}
|
||||
|
||||
// without type annotation
|
||||
this._map2 = { [ik]: iv };
|
||||
>this._map2 = { [ik]: iv } : { [x: string]: V; }
|
||||
>this._map2 : any
|
||||
>this : any
|
||||
>_map2 : any
|
||||
>{ [ik]: iv } : { [x: string]: V; }
|
||||
>[ik] : V
|
||||
>ik : string
|
||||
>iv : V
|
||||
|
||||
};
|
||||
|
||||
/** @type {Multimap<"a" | "b", number>} with type annotation */
|
||||
const map = new Multimap("a", 1);
|
||||
>map : Multimap<"a" | "b", number>
|
||||
>new Multimap("a", 1) : Multimap<"a" | "b", number>
|
||||
>Multimap : typeof Multimap
|
||||
>"a" : "a"
|
||||
>1 : 1
|
||||
|
||||
// without type annotation
|
||||
const map2 = new Multimap("m", 2);
|
||||
>map2 : Multimap<string, number>
|
||||
>new Multimap("m", 2) : Multimap<string, number>
|
||||
>Multimap : typeof Multimap
|
||||
>"m" : "m"
|
||||
>2 : 2
|
||||
|
||||
/** @type {number} */
|
||||
var n = map._map['hi']
|
||||
>n : number
|
||||
>map._map['hi'] : number
|
||||
>map._map : { [s: string]: number; }
|
||||
>map : Multimap<"a" | "b", number>
|
||||
>_map : { [s: string]: number; }
|
||||
>'hi' : "hi"
|
||||
|
||||
/** @type {number} */
|
||||
var n = map._map2['hi']
|
||||
>n : number
|
||||
>map._map2['hi'] : number
|
||||
>map._map2 : { [x: string]: number; }
|
||||
>map : Multimap<"a" | "b", number>
|
||||
>_map2 : { [x: string]: number; }
|
||||
>'hi' : "hi"
|
||||
|
||||
/** @type {number} */
|
||||
var n = map2._map['hi']
|
||||
>n : number
|
||||
>map2._map['hi'] : number
|
||||
>map2._map : { [s: string]: number; }
|
||||
>map2 : Multimap<string, number>
|
||||
>_map : { [s: string]: number; }
|
||||
>'hi' : "hi"
|
||||
|
||||
/** @type {number} */
|
||||
var n = map._map2['hi']
|
||||
>n : number
|
||||
>map._map2['hi'] : number
|
||||
>map._map2 : { [x: string]: number; }
|
||||
>map : Multimap<"a" | "b", number>
|
||||
>_map2 : { [x: string]: number; }
|
||||
>'hi' : "hi"
|
||||
|
||||
|
|
@ -4,17 +4,29 @@
|
|||
// @noEmit: true
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @template {string} K
|
||||
* @template V
|
||||
* @param {string} ik
|
||||
* @param {V} iv
|
||||
*/
|
||||
function Multimap() {
|
||||
/** @type {Object<string, V>} TODO: Remove the prototype from the fresh object */
|
||||
function Multimap(ik, iv) {
|
||||
/** @type {{ [s: string]: V }} */
|
||||
this._map = {};
|
||||
// without type annotation
|
||||
this._map2 = { [ik]: iv };
|
||||
};
|
||||
|
||||
var Ns = {}
|
||||
/** @type {Multimap<"a" | "b", number>} */
|
||||
const map = new Multimap();
|
||||
/** @type {Multimap<"a" | "b", number>} with type annotation */
|
||||
const map = new Multimap("a", 1);
|
||||
// without type annotation
|
||||
const map2 = new Multimap("m", 2);
|
||||
|
||||
/** @type {number} */
|
||||
const n = map._map['hi']
|
||||
var n = map._map['hi']
|
||||
/** @type {number} */
|
||||
var n = map._map2['hi']
|
||||
/** @type {number} */
|
||||
var n = map2._map['hi']
|
||||
/** @type {number} */
|
||||
var n = map._map2['hi']
|
||||
|
||||
|
|
Loading…
Reference in a new issue