-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(optional chaining): add support for optional chaining and nullis…
…h coalescing
- Loading branch information
Showing
8 changed files
with
198 additions
and
105 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,106 @@ | ||
{ | ||
"name": "@wessberg/ts-evaluator", | ||
"version": "0.0.23", | ||
"description": "An interpreter for Typescript that can evaluate an arbitrary Node within a Typescript AST", | ||
"scripts": { | ||
"generate:readme": "scaffold readme --yes", | ||
"generate:license": "scaffold license --yes", | ||
"generate:contributing": "scaffold contributing --yes", | ||
"generate:coc": "scaffold coc --yes", | ||
"generate:changelog": "standard-changelog --first-release", | ||
"generate:all": "npm run generate:license & npm run generate:contributing & npm run generate:coc & npm run generate:readme && npm run generate:changelog", | ||
"clean": "rm -rf dist", | ||
"lint": "tsc --noEmit && tslint -c tslint.json --project tsconfig.json", | ||
"prettier": "prettier --write '{src,test,documentation}/**/*.{js,ts,json,html,xml,css,md}'", | ||
"test": "ava", | ||
"prebuild": "npm run clean", | ||
"build": "npm run rollup", | ||
"rollup": "rollup -c rollup.config.js", | ||
"preversion": "npm run lint && NODE_ENV=production npm run build", | ||
"version": "npm run generate:all && git add .", | ||
"release": "np --no-cleanup --no-yarn" | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"ts", | ||
"interpreter", | ||
"evaluate", | ||
"evaluator", | ||
"ast" | ||
], | ||
"files": [ | ||
"dist/**/*.*" | ||
], | ||
"contributors": [ | ||
{ | ||
"name": "Frederik Wessberg", | ||
"email": "frederikwessberg@hotmail.com", | ||
"url": "https://github.com/wessberg", | ||
"imageUrl": "https://avatars2.githubusercontent.com/u/20454213?s=460&v=4", | ||
"role": "Lead Developer", | ||
"twitter": "FredWessberg" | ||
} | ||
], | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@wessberg/scaffold": "1.0.19", | ||
"@wessberg/rollup-plugin-ts": "1.1.66", | ||
"@wessberg/ts-config": "0.0.41", | ||
"standard-changelog": "2.0.15", | ||
"tslint": "5.20.0", | ||
"ava": "2.4.0", | ||
"prettier": "^1.18.2", | ||
"pretty-quick": "^2.0.0", | ||
"husky": "^3.0.9", | ||
"np": "^5.1.1", | ||
"find-up": "^4.1.0", | ||
"ts-node": "^8.4.1", | ||
"rollup": "^1.23.1" | ||
}, | ||
"dependencies": { | ||
"@types/deasync": "0.1.0", | ||
"@types/node": "12.7.12", | ||
"@types/object-path": "0.11.0", | ||
"chalk": "2.4.2", | ||
"object-path": "0.11.4", | ||
"tslib": "1.10.0", | ||
"typescript": "3.6.4" | ||
}, | ||
"optionalDependencies": { | ||
"@types/jsdom": "12.2.4", | ||
"jsdom": "15.1.1", | ||
"deasync": "0.1.15" | ||
}, | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"browser": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts", | ||
"typings": "./dist/esm/index.d.ts", | ||
"es2015": "./dist/esm/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wessberg/ts-evaluator.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/wessberg/ts-evaluator/issues" | ||
}, | ||
"engines": { | ||
"node": ">=10.1.0" | ||
}, | ||
"ava": { | ||
"files": [ | ||
"test/**/*.test.ts" | ||
], | ||
"compileEnhancements": false, | ||
"extensions": [ | ||
"ts" | ||
], | ||
"require": [ | ||
"ts-node/register" | ||
] | ||
} | ||
"name": "@wessberg/ts-evaluator", | ||
"version": "0.0.23", | ||
"description": "An interpreter for Typescript that can evaluate an arbitrary Node within a Typescript AST", | ||
"scripts": { | ||
"generate:readme": "scaffold readme --yes", | ||
"generate:license": "scaffold license --yes", | ||
"generate:contributing": "scaffold contributing --yes", | ||
"generate:coc": "scaffold coc --yes", | ||
"generate:changelog": "standard-changelog --first-release", | ||
"generate:all": "npm run generate:license & npm run generate:contributing & npm run generate:coc & npm run generate:readme && npm run generate:changelog", | ||
"clean": "rm -rf dist", | ||
"lint": "tsc --noEmit && tslint -c tslint.json --project tsconfig.json", | ||
"prettier": "prettier --write '{src,test,documentation}/**/*.{js,ts,json,html,xml,css,md}'", | ||
"test": "ava", | ||
"prebuild": "npm run clean", | ||
"build": "npm run rollup", | ||
"rollup": "rollup -c rollup.config.js", | ||
"preversion": "npm run lint && NODE_ENV=production npm run build", | ||
"version": "npm run generate:all && git add .", | ||
"release": "np --no-cleanup --no-yarn" | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"ts", | ||
"interpreter", | ||
"evaluate", | ||
"evaluator", | ||
"ast" | ||
], | ||
"files": [ | ||
"dist/**/*.*" | ||
], | ||
"contributors": [ | ||
{ | ||
"name": "Frederik Wessberg", | ||
"email": "frederikwessberg@hotmail.com", | ||
"url": "https://github.com/wessberg", | ||
"imageUrl": "https://avatars2.githubusercontent.com/u/20454213?s=460&v=4", | ||
"role": "Lead Developer", | ||
"twitter": "FredWessberg", | ||
"github": "wessberg" | ||
} | ||
], | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@wessberg/scaffold": "1.0.19", | ||
"@wessberg/rollup-plugin-ts": "1.1.74", | ||
"@wessberg/ts-config": "0.0.42", | ||
"standard-changelog": "2.0.15", | ||
"tslint": "5.20.1", | ||
"ava": "2.4.0", | ||
"prettier": "^1.19.1", | ||
"pretty-quick": "^2.0.1", | ||
"husky": "^3.0.9", | ||
"np": "^5.1.3", | ||
"find-up": "^4.1.0", | ||
"ts-node": "^8.4.1", | ||
"rollup": "^1.26.4", | ||
"typescript": "3.7.2" | ||
}, | ||
"dependencies": { | ||
"@types/deasync": "0.1.0", | ||
"@types/node": "12.12.7", | ||
"@types/object-path": "0.11.0", | ||
"chalk": "3.0.0", | ||
"object-path": "0.11.4", | ||
"tslib": "1.10.0" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^3.x" | ||
}, | ||
"optionalDependencies": { | ||
"@types/jsdom": "12.2.4", | ||
"jsdom": "15.2.1", | ||
"deasync": "0.1.15" | ||
}, | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"browser": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts", | ||
"typings": "./dist/esm/index.d.ts", | ||
"es2015": "./dist/esm/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wessberg/ts-evaluator.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/wessberg/ts-evaluator/issues" | ||
}, | ||
"engines": { | ||
"node": ">=10.1.0" | ||
}, | ||
"ava": { | ||
"files": [ | ||
"test/**/*.test.ts" | ||
], | ||
"compileEnhancements": false, | ||
"extensions": [ | ||
"ts" | ||
], | ||
"require": [ | ||
"ts-node/register" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import test from "ava"; | ||
import {prepareTest} from "../setup"; | ||
|
||
test("Supports nullish coalescing with null-like values. #1", t => { | ||
const {evaluate} = prepareTest( | ||
// language=TypeScript | ||
` | ||
const foo = ""; | ||
const bar = foo ?? "bar"; | ||
`, | ||
`foo ?? "bar"` | ||
); | ||
|
||
const result = evaluate(); | ||
|
||
if (!result.success) t.fail(result.reason.stack); | ||
else { | ||
t.deepEqual(result.value, ""); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import test from "ava"; | ||
import {prepareTest} from "../setup"; | ||
|
||
test("Supports optional CallExpressions. #1", t => { | ||
const {evaluate} = prepareTest( | ||
// language=TypeScript | ||
` | ||
const foo = {bar: {baz: undefined}}; | ||
const bar = foo.bar.baz?.(); | ||
`, | ||
"foo.bar.baz?.()" | ||
); | ||
|
||
const result = evaluate(); | ||
|
||
if (!result.success) t.fail(result.reason.stack); | ||
else { | ||
t.deepEqual(result.value, undefined); | ||
} | ||
}); | ||
|
||
test("Supports optional PropertyAccessExpressions. #1", t => { | ||
const {evaluate} = prepareTest( | ||
// language=TypeScript | ||
` | ||
const foo = {bar: undefined}; | ||
const bar = foo.bar?.baz; | ||
`, | ||
"foo.bar?.baz" | ||
); | ||
|
||
const result = evaluate(); | ||
|
||
if (!result.success) t.fail(result.reason.stack); | ||
else { | ||
t.deepEqual(result.value, undefined); | ||
} | ||
}); | ||
|
||
test("Supports optional ElementAccessExpressions. #1", t => { | ||
const {evaluate} = prepareTest( | ||
// language=TypeScript | ||
` | ||
const foo = {bar: undefined}; | ||
const bar = foo.bar?.["baz"]; | ||
`, | ||
`foo.bar?.["baz"]` | ||
); | ||
|
||
const result = evaluate(); | ||
|
||
if (!result.success) t.fail(result.reason.stack); | ||
else { | ||
t.deepEqual(result.value, undefined); | ||
} | ||
}); |