3

When compiling the following typescript:

class Node {
}

It works in the playground but not using VS2013 or grunt-typescript which generates the error

TS2000: Duplicate identifier 'Node'

I guess it can only be because its a reserved word but I have searched the typescript spec for reserved words and can't find any. Is there a list available and why is such a common class name reserved?

2 Answers 2

3

Node is already an object in JavaScript. It's not a reserved word, but it is a built-in thing that you don't want to accidently overwrite at runtime (you would break other libraries).

> Node.prototype
    Node {insertBefore: function, replaceChild: function, removeChild: function, appendChild: function, hasChildNodes: function…}
Sign up to request clarification or add additional context in comments.

Comments

0

Ok it looks like there is a library file:

lib.d.ts

That contains 8 KLOC of typescript without any form of module or namespace that is causing me all sorts of name clashes. Frustrating given the compiler doesn't give any locations and I spend hours tearing apart my build system looking for some sort of fault.

1 Comment

The lib.d.ts gives the typescript compiler information about standard javascript methods (methodname, typed parameters and typed returnvalue). This is exactly why you want to use typescript...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.