mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
152 lines
6.2 KiB
Plaintext
152 lines
6.2 KiB
Plaintext
first.js(6,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
first.js(8,13): error TS2749: 'Wagon' refers to a value, but is being used as a type here. Did you mean 'typeof Wagon'?
|
|
first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons?: Wagon[] | undefined) => number; }' is not a constructor function type.
|
|
first.js(44,4): error TS2339: Property 'numberOxen' does not exist on type 'Sql'.
|
|
first.js(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type.
|
|
generic.js(6,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
generic.js(9,23): error TS2507: Type '<T>(flavour: T) => void' is not a constructor function type.
|
|
generic.js(11,21): error TS2339: Property 'flavour' does not exist on type 'Chowder'.
|
|
generic.js(15,12): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.
|
|
generic.js(17,27): error TS2554: Expected 0 arguments, but got 1.
|
|
generic.js(18,9): error TS2339: Property 'flavour' does not exist on type 'Chowder'.
|
|
generic.js(20,32): error TS2554: Expected 0 arguments, but got 1.
|
|
second.ts(5,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
second.ts(8,25): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type.
|
|
second.ts(14,25): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons?: Wagon[] | undefined) => number; }' is not a constructor function type.
|
|
second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'.
|
|
|
|
|
|
==== first.js (5 errors) ====
|
|
/**
|
|
* @constructor
|
|
* @param {number} numberOxen
|
|
*/
|
|
function Wagon(numberOxen) {
|
|
this.numberOxen = numberOxen
|
|
~~~~
|
|
!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
}
|
|
/** @param {Wagon[]=} wagons */
|
|
~~~~~
|
|
!!! error TS2749: 'Wagon' refers to a value, but is being used as a type here. Did you mean 'typeof Wagon'?
|
|
Wagon.circle = function (wagons) {
|
|
return wagons ? wagons.length : 3.14;
|
|
}
|
|
/** @param {*[]=} supplies - *[]= is my favourite type */
|
|
Wagon.prototype.load = function (supplies) {
|
|
}
|
|
/** @param {*[]=} supplies - Yep, still a great type */
|
|
Wagon.prototype.weight = supplies => supplies ? supplies.length : -1
|
|
Wagon.prototype.speed = function () {
|
|
return this.numberOxen / this.weight()
|
|
}
|
|
// ok
|
|
class Sql extends Wagon {
|
|
~~~~~
|
|
!!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons?: Wagon[] | undefined) => number; }' is not a constructor function type.
|
|
constructor() {
|
|
super(); // error: not enough arguments
|
|
this.foonly = 12
|
|
}
|
|
/**
|
|
* @param {Array.<string>} files
|
|
* @param {"csv" | "json" | "xmlolololol"} format
|
|
* This is not assignable, so should have a type error
|
|
*/
|
|
load(files, format) {
|
|
if (format === "xmlolololol") {
|
|
throw new Error("please do not use XML. It was a joke.");
|
|
}
|
|
else {
|
|
super.speed() // run faster
|
|
if (super.weight() < 0) {
|
|
// ????????????????????????
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var db = new Sql();
|
|
db.numberOxen = db.foonly
|
|
~~~~~~~~~~
|
|
!!! error TS2339: Property 'numberOxen' does not exist on type 'Sql'.
|
|
|
|
// error, can't extend a TS constructor function
|
|
class Drakkhen extends Dragon {
|
|
~~~~~~
|
|
!!! error TS2507: Type '(numberEaten: number) => void' is not a constructor function type.
|
|
|
|
}
|
|
|
|
==== second.ts (4 errors) ====
|
|
/**
|
|
* @constructor
|
|
*/
|
|
function Dragon(numberEaten: number) {
|
|
this.numberEaten = numberEaten
|
|
~~~~
|
|
!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
}
|
|
// error!
|
|
class Firedrake extends Dragon {
|
|
~~~~~~
|
|
!!! error TS2507: Type '(numberEaten: number) => void' is not a constructor function type.
|
|
constructor() {
|
|
super();
|
|
}
|
|
}
|
|
// ok
|
|
class Conestoga extends Wagon {
|
|
~~~~~
|
|
!!! error TS2507: Type '{ (numberOxen: number): void; circle: (wagons?: Wagon[] | undefined) => number; }' is not a constructor function type.
|
|
constructor(public drunkOO: true) {
|
|
// error: wrong type
|
|
super('nope');
|
|
}
|
|
// should error since others is not optional
|
|
static circle(others: (typeof Wagon)[]) {
|
|
return others.length
|
|
}
|
|
}
|
|
var c = new Conestoga(true);
|
|
c.drunkOO
|
|
c.numberOxen
|
|
~~~~~~~~~~
|
|
!!! error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'.
|
|
|
|
==== generic.js (7 errors) ====
|
|
/**
|
|
* @template T
|
|
* @param {T} flavour
|
|
*/
|
|
function Soup(flavour) {
|
|
this.flavour = flavour
|
|
~~~~
|
|
!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
}
|
|
/** @extends {Soup<{ claim: "ignorant" | "malicious" }>} */
|
|
class Chowder extends Soup {
|
|
~~~~
|
|
!!! error TS2507: Type '<T>(flavour: T) => void' is not a constructor function type.
|
|
log() {
|
|
return this.flavour
|
|
~~~~~~~
|
|
!!! error TS2339: Property 'flavour' does not exist on type 'Chowder'.
|
|
}
|
|
}
|
|
|
|
var soup = new Soup(1);
|
|
~~~~~~~~~~~
|
|
!!! error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.
|
|
soup.flavour
|
|
var chowder = new Chowder({ claim: "ignorant" });
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2554: Expected 0 arguments, but got 1.
|
|
chowder.flavour.claim
|
|
~~~~~~~
|
|
!!! error TS2339: Property 'flavour' does not exist on type 'Chowder'.
|
|
var errorNoArgs = new Chowder();
|
|
var errorArgType = new Chowder(0);
|
|
~
|
|
!!! error TS2554: Expected 0 arguments, but got 1.
|
|
|
|
|