DefinitelyTyped/types/luaparse/luaparse-tests.ts
thomasfn ef685c5a82 [luaparse] Added more complete typings for the luaparse library (#35664)
* Added more complete typings for the luaparse library, including definitions for the lua ast.

* Added typing for token and corrected onCreateScope and onDestroyScope options.

* Correct node typing in onCreateNode option.

* Corrected body property of ForGenericStatement.

* Added LogicalExpression to ast.

* Removed const enum and replaced types with raw strings. Also tidied up Node type by utilising Statement and Expression.

* Split some long comments into multiple lines. Removed overridden line length linting rule.
2019-05-31 08:42:58 -07:00

20 lines
532 B
TypeScript

import luaparse = require("luaparse");
const luacode = "-- this is hello world in lua.\nprint('hello world')";
// $ExpectType Chunk
const ast1 = luaparse.parse(luacode);
console.log(JSON.stringify(ast1));
// $ExpectType Chunk
const ast2 = luaparse.parse(luacode, {comments: false});
console.log(JSON.stringify(ast2));
// $ExpectType Parser
const ast3 = luaparse.parse({wait: true});
console.log(JSON.stringify(ast3));
// $ExpectType Parser
const ast4 = luaparse.parse(luacode, {wait: true});
console.log(JSON.stringify(ast4));