mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-27 03:02:50 +00:00
* 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.
20 lines
532 B
TypeScript
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));
|