7 kyu
Learning TypeScript. Classes & Interfaces. Inheritance
488vguzev
Loading description...
Fundamentals
Object-oriented Programming
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
The description is incorrect: there are 5 arguments, not 4.
Is the
declare
necessary? What purpose does it serve? Can you please point me to the relevant documentation to learn more about whats going on here? My solution worked when I commented it out.Is this a "Learning TypeScript" series? Even the orignal one is more friendly than this.
I'm totally new to TypeScript.And I need to search for more informations in every kata of this series.
Seems to be broken. I'm getting
/runner/node_modules/ts-node/src/index.ts:307 throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset)) ^ TSError: ⨯ Unable to compile TypeScript spec.ts (3,39): File '/home/codewarrior/solution.ts' is not a module. (2306) spec.ts (55,77): Property 'introduce' does not exist on type 'Solution'. (2339) at getOutput (/runner/node_modules/ts-node/src/index.ts:307:15) at /runner/node_modules/ts-node/src/index.ts:336:16 at Object.compile (/runner/node_modules/ts-node/src/index.ts:498:11) at Module.m._compile (/runner/node_modules/ts-node/src/index.ts:392:43) at Module._extensions..js (module.js:635:10) at Object.require.extensions.(anonymous function) [as .ts] (/runner/node_modules/ts-node/src/index.ts:395:12) at Module.load (module.js:545:32) at tryModuleLoad (module.js:508:12) at Function.Module._load (module.js:500:3) at Module.require (module.js:568:17) at require (internal/module.js:11:18) at /runner/node_modules/mocha/lib/mocha.js:231:27 at Array.forEach (<anonymous>) at Mocha.loadFiles (/runner/node_modules/mocha/lib/mocha.js:228:14) at Mocha.run (/runner/node_modules/mocha/lib/mocha.js:514:10) at Object.<anonymous> (/runner/node_modules/mocha/bin/_mocha:480:18) at Module._compile (module.js:624:30) at Object.Module._extensions..js (module.js:635:10) at Module.load (module.js:545:32) at tryModuleLoad (module.js:508:12) at Function.Module._load (module.js:500:3) at Function.Module.runMain (module.js:665:10) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
I've just checked - everything works as expected. There must be some problems with your code, or perhaps it was temporary problem with Codewars' infrastructure. Please, try again and if problem still exists share your code in comments.
This comment has been hidden.
This comment has been hidden.
Not an issue. Your classes are not exported.
Approved
What is the purpose of the
IAnimal
variable declaration?IMHO the solution doesn't need it, but then again, I just started with TypeScript.
And why is
introduce
declared as returningvoid
if it is supposed to return astring
? Is that part of the task?This is actually a "hack" to define the constructor parameters in interfaces. For example see how Typescript's team did the same in defining Object interface: https://github.com/Microsoft/TypeScript/blob/master/lib/lib.d.ts They are declaring an interface and afterwards a variable with a name matching exactly the interface-name. This is also the way to type static functions. So, yes, this is part of the task.
P.S.
introduce
is now returningstring
. Thanks for your report!This comment has been hidden.