jindw / xmldom

A PURE JS W3C Standard based(XML DOM Level2 CORE) DOMParser and XMLSerializer.
Other
819 stars 265 forks source link

error TS2304: Cannot find name 'DOMImplementation' #220

Open ghost opened 7 years ago

ghost commented 7 years ago

Hi there, I got this error when compiling:

>tsc --lib ES2015 app3
node_modules/@types/xmldom/index.d.ts(13,16): error TS2304: Cannot find name 'DOMImplementation'.
node_modules/@types/xmldom/index.d.ts(26,64): error TS2304: Cannot find name 'Document'.
node_modules/@types/xmldom/index.d.ts(30,33): error TS2304: Cannot find name 'Node'.

tsconfig.json

{
    "compilerOptions": {
        "target": "es6",
        //"watch": true,
        "module": "commonjs",
        //"moduleResolution": "node",
        //"sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true
        //"allowJs": true,
        //"removeComments": false,
        //"noImplicitAny": true,
        //"suppressImplicitAnyIndexErrors": true,
        //"allowSyntheticDefaultImports": true
        //"noEmitOnError": false,
        //"preserveConstEnums": true
        //,"typeRoots": [
          //  "./node_modules/@types/"
        //]
        //,"types" : [ "node", "locutus" ] //, "jasmine", "core-js"
    }
    //"compileOnSave": true,
    //"exclude": [
      //  "./node_modules/*"
    //]
}

David

koldoon commented 6 years ago

@ghost, add this options to your compilerOptions:

 "lib": [
            "es5",
            "es6",
            "es2016",
            "dom"
        ],
pauldraper commented 5 years ago

@koldoon that brings in a bunch of incorrect typings though.

It says a whole bunch of things exist on the global object (name, alert, blur, etc.) that do not.

And then I loose type safety.

karfau commented 4 years ago

Since the types for this project are not maintained here but in https://github.com/DefinitelyTyped/DefinitelyTyped this one should be closed as it has been reported as https://github.com/DefinitelyTyped/DefinitelyTyped/issues/26745

(Maintenance has been picked up for the project in https://github.com/xmldom/xmldom, so there is a chance that stuff get's fixed at some point.)

PS: I files a PR with a fix today and it can also be used as a workaround