File: genericRespecialization1.ts

package info (click to toggle)
node-typescript 4.8.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 523,068 kB
  • sloc: javascript: 1,735,777; makefile: 7; sh: 1
file content (75 lines) | stat: -rw-r--r-- 2,710 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/// <reference path='fourslash.ts' />

//// class Food {
////     private amount: number;
////     constructor(public name: string) {
////         this.amount = 100;
////     }
////     public eat(amountToEat: number): boolean {
////         this.amount -= amountToEat;
////         if (this.amount <= 0) {
////             this.amount = 0;
////             return false;
////         }
////         else {
////             return true;
////         }
////     }
//// }
//// class IceCream extends Food {
////     private isDairyFree: boolean;
////     constructor(public flavor: string) {
////         super("Ice Cream");
////     }
//// }
//// class Cookie extends Food {
////     constructor(public flavor: string, public isGlutenFree: boolean) {
////         super("Cookie");
////     }
//// }
//// class Slug {
////     // This is NOT a food!!!
//// }
//// class GenericMonster<T extends Food, V> {
////     private name: string;
////     private age: number;
////     private isFriendly: boolean;
////     constructor(name: string, age: number, isFriendly: boolean, private food: T, public variant: V) {
////         this.name = name;
////         this.age = age;
////         this.isFriendly = isFriendly;
////     }
////     public getFood(): T {
////         return this.food;
////     }
////     public getVariant(): V {
////         return this.variant;
////     }
////     public eatFood(amountToEat: number): boolean {
////         return this.food.eat(amountToEat);
////     }
////     public sayGreeting(): string {
////         return ("My name is " + this.name + ", and my age is " + this.age + ".  I enjoy eating " + this.food.name + " and my variant is " + this.variant);
////     }
//// }
//// class GenericPlanet<T extends GenericMonster</*2*/Cookie, any>> {
////     constructor(public name: string, public solarSystem: string, public species: T) { }
//// }
//// var cookie = new Cookie("Chocolate Chip", false);
//// var cookieMonster = new GenericMonster<Cookie, string>("Cookie Monster", 50, true, cookie, "hello");
//// var sesameStreet = new GenericPlanet<GenericMonster<Cookie, string>>("Sesame Street", "Alpha Centuri", cookieMonster);
//// class GenericPlanet2<T extends Food, V>{
////     constructor(public name: string, public solarSystem: string, public species: GenericMonster<T, V>) { }
//// }
////  /*1*/

verify.noErrors();
goTo.marker('1');
edit.insertLine('');
edit.insertLine('');
verify.noErrors();
goTo.marker('2');
edit.deleteAtCaret("Cookie".length);
edit.insert("any");
verify.noErrors();
edit.insertLine('var narnia = new GenericPlanet2<Cookie, string>('); // shouldn't crash at this point