我已成功使用ts.SyntaxKind.NullKeyword
检查是否使用了null
关键字:
import * as ts from "typescript";
import * as Lint from "tslint";
if (right === ts.SyntaxKind.NullKeyword) {
this.addFailure(this.createFailure(position, expressionWidth, Rule.EQ_FAILURE_STRING));
}
现在我想做同样的事情,除了未定义的关键字:
import * as ts from "typescript";
import * as Lint from "tslint";
if (right === ts.SyntaxKind.UndefinedKeyword) {
this.addFailure(this.createFailure(position, expressionWidth, Rule.EQ_FAILURE_STRING));
}
但是当我这样做时,会出现此错误:
[ts] Property 'UndefinedKeyword' does not exist on type 'typeof SyntaxKind'.
我以为它是我的tslint
版本还是我的typescript
版本,但它们现在都没有那么旧了。
Package.json:
{
"name": "classic-pm-frontend",
"version": "0.1.1",
"description": "",
"main": "",
"dependencies": {
"@progress/kendo-ui": "2018.1.403",
"adal-angular": "1.0.11",
"angular": "1.5.8",
"@types/lodash": "ts2.0",
"angular-animate": "1.5.8",
"angular-aria": "1.5.8",
"angular-crumble": "0.2.2",
"angular-drag-and-drop-lists": "1.4.0",
"angular-local-storage": "0.2.7",
"angular-material": "1.1.0",
"angular-messages": "1.5.8",
"angular-moment": "1.0.1",
"angular-native-dragdrop": "1.2.2",
"angular-resource": "1.5.8",
"angular-route": "1.5.8",
"angular-ui-tree": "2.22.2",
"drag-drop-webkit-mobile": "1.2.0",
"jquery": "3.1.1",
"jsplumb": "2.2.10",
"loader-utils": "1.1.0",
"lodash": "^4.17.10",
"moment": "2.14.1",
"ng-infinite-scroll": "1.3.0",
"ng-wig": "3.0.16",
"npm": "5.8.0",
"update": "0.7.4"
},
"devDependencies": {
"angular-cli": "^1.0.0-beta.28.3",
"angular-mocks": "1.5.8",
"awesome-typescript-loader": "^5.2.0",
"baggage-loader": "0.2.4",
"copy-webpack-plugin": "2.1.6",
"css-loader": "0.23.1",
"exports-loader": "0.6.3",
"expose-loader": "0.7.1",
"express": "4.14.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "0.8.5",
"html-loader": "0.4.3",
"html-webpack-plugin": "2.22.0",
"imports-loader": "0.6.5",
"jasmine-core": "2.4.1",
"karma": "0.13.22",
"karma-jasmine": "0.3.8",
"karma-junit-reporter": "0.4.2",
"karma-phantomjs-launcher": "1.0.1",
"ngtemplate-loader": "1.3.1",
"node-sass": "3.8.0",
"normalize.css": "4.2.0",
"phantomjs-prebuilt": "2.1.12",
"rimraf": "2.5.4",
"sass-loader": "3.2.3",
"script-loader": "0.7.0",
"source-map-loader": "0.1.5",
"ts-loader": "0.8.2",
"tslint": "^5.2.0",
"tslint-loader": "^3.6.0",
"typedoc": "0.7.1",
"typescript": "^2.9.2",
"typings": "1.3.2",
"url-loader": "0.5.7",
"webpack": "^3.12.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5",
"webpack-fail-plugin": "1.0.5"
},
"scripts": {
"postinstall": "npm rebuild node-sass rimraf",
"prepublish": "typings install",
"build": "rimraf dist && webpack --progress --color",
"build-watch": "webpack --progress --color --watch",
"build-test": "webpack --config webpack.config.test.js --progress --color",
"build-test-watch": "webpack --config webpack.config.test.js --progress --color --watch",
"test": "karma start --single-run",
"test-watch": "karma start --auto-watch",
"dev": "webpack-dev-server --port 3000 --open --inline --content-base dist/",
"docs": "rimraf distdoc && typedoc --out ./distdoc --tsconfig tsconfig.json --ignoreCompilerErrors 2> $null && exit 0",
"typedoc": "typedoc -h"
},
"author": "Classic Group Ltd",
"license": "UNLICENSED",
"repository": {
"type": "git",
"url": "https://classicgroup.visualstudio.com/defaultcollection/_git/Classic%20PM%20Front%20End"
}
}
如何消除错误