@jackctaylor/roblox-ts 3.0.0-projectrefs.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +716 -0
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/include/Promise.lua +2068 -0
- package/include/RuntimeLib.lua +258 -0
- package/out/CLI/cli.d.ts +2 -0
- package/out/CLI/cli.js +41 -0
- package/out/CLI/commands/build.d.ts +7 -0
- package/out/CLI/commands/build.js +438 -0
- package/out/CLI/errors/CLIError.d.ts +4 -0
- package/out/CLI/errors/CLIError.js +12 -0
- package/out/CLI/index.d.ts +3 -0
- package/out/CLI/index.js +22 -0
- package/out/CLI/test.d.ts +1 -0
- package/out/CLI/test.js +82 -0
- package/out/CLI/util/patchFs.d.ts +1 -0
- package/out/CLI/util/patchFs.js +26 -0
- package/out/Project/classes/VirtualFileSystem.d.ts +14 -0
- package/out/Project/classes/VirtualFileSystem.js +102 -0
- package/out/Project/classes/VirtualProject.d.ts +15 -0
- package/out/Project/classes/VirtualProject.js +121 -0
- package/out/Project/functions/buildProject.d.ts +18 -0
- package/out/Project/functions/buildProject.js +48 -0
- package/out/Project/functions/buildProjectReferences.d.ts +3 -0
- package/out/Project/functions/buildProjectReferences.js +78 -0
- package/out/Project/functions/buildSolution.d.ts +10 -0
- package/out/Project/functions/buildSolution.js +97 -0
- package/out/Project/functions/checkFileName.d.ts +1 -0
- package/out/Project/functions/checkFileName.js +18 -0
- package/out/Project/functions/checkRojoConfig.d.ts +4 -0
- package/out/Project/functions/checkRojoConfig.js +26 -0
- package/out/Project/functions/cleanup.d.ts +2 -0
- package/out/Project/functions/cleanup.js +30 -0
- package/out/Project/functions/compileFiles.d.ts +4 -0
- package/out/Project/functions/compileFiles.js +160 -0
- package/out/Project/functions/compileProject.d.ts +14 -0
- package/out/Project/functions/compileProject.js +71 -0
- package/out/Project/functions/copyFiles.d.ts +3 -0
- package/out/Project/functions/copyFiles.js +13 -0
- package/out/Project/functions/copyInclude.d.ts +2 -0
- package/out/Project/functions/copyInclude.js +17 -0
- package/out/Project/functions/copyItem.d.ts +3 -0
- package/out/Project/functions/copyItem.js +27 -0
- package/out/Project/functions/createNodeModulesPathMapping.d.ts +1 -0
- package/out/Project/functions/createNodeModulesPathMapping.js +31 -0
- package/out/Project/functions/createPathTranslator.d.ts +4 -0
- package/out/Project/functions/createPathTranslator.js +22 -0
- package/out/Project/functions/createProgramFactory.d.ts +3 -0
- package/out/Project/functions/createProgramFactory.js +31 -0
- package/out/Project/functions/createProjectData.d.ts +2 -0
- package/out/Project/functions/createProjectData.js +102 -0
- package/out/Project/functions/createProjectProgram.d.ts +3 -0
- package/out/Project/functions/createProjectProgram.js +11 -0
- package/out/Project/functions/getChangedFilePaths.d.ts +2 -0
- package/out/Project/functions/getChangedFilePaths.js +47 -0
- package/out/Project/functions/getChangedSourceFiles.d.ts +2 -0
- package/out/Project/functions/getChangedSourceFiles.js +19 -0
- package/out/Project/functions/getParsedCommandLine.d.ts +3 -0
- package/out/Project/functions/getParsedCommandLine.js +41 -0
- package/out/Project/functions/getProjectReferences.d.ts +2 -0
- package/out/Project/functions/getProjectReferences.js +65 -0
- package/out/Project/functions/getResolvedProjectReferences.d.ts +3 -0
- package/out/Project/functions/getResolvedProjectReferences.js +43 -0
- package/out/Project/functions/setupProjectWatchProgram.d.ts +2 -0
- package/out/Project/functions/setupProjectWatchProgram.js +352 -0
- package/out/Project/functions/setupSolutionWatchProgram.d.ts +2 -0
- package/out/Project/functions/setupSolutionWatchProgram.js +355 -0
- package/out/Project/functions/tryRemoveOutput.d.ts +2 -0
- package/out/Project/functions/tryRemoveOutput.js +30 -0
- package/out/Project/functions/validateCompilerOptions.d.ts +2 -0
- package/out/Project/functions/validateCompilerOptions.js +87 -0
- package/out/Project/index.d.ts +4 -0
- package/out/Project/index.js +20 -0
- package/out/Project/preEmitDiagnostics/fileUsesCommentDirectives.d.ts +3 -0
- package/out/Project/preEmitDiagnostics/fileUsesCommentDirectives.js +28 -0
- package/out/Project/transformers/builtin/transformPaths.d.ts +5 -0
- package/out/Project/transformers/builtin/transformPaths.js +129 -0
- package/out/Project/transformers/builtin/transformTypeReferenceDirectives.d.ts +2 -0
- package/out/Project/transformers/builtin/transformTypeReferenceDirectives.js +23 -0
- package/out/Project/transformers/createTransformerList.d.ts +4 -0
- package/out/Project/transformers/createTransformerList.js +87 -0
- package/out/Project/transformers/createTransformerWatcher.d.ts +3 -0
- package/out/Project/transformers/createTransformerWatcher.js +59 -0
- package/out/Project/transformers/getPluginConfigs.d.ts +2 -0
- package/out/Project/transformers/getPluginConfigs.js +34 -0
- package/out/Project/util/createReadBuildProgramHost.d.ts +5 -0
- package/out/Project/util/createReadBuildProgramHost.js +15 -0
- package/out/Project/util/getCustomPreEmitDiagnostics.d.ts +4 -0
- package/out/Project/util/getCustomPreEmitDiagnostics.js +13 -0
- package/out/Project/util/isCompilableFile.d.ts +1 -0
- package/out/Project/util/isCompilableFile.js +18 -0
- package/out/Project/util/walkDirectorySync.d.ts +1 -0
- package/out/Project/util/walkDirectorySync.js +22 -0
- package/out/Shared/classes/Lazy.d.ts +8 -0
- package/out/Shared/classes/Lazy.js +22 -0
- package/out/Shared/classes/LogService.d.ts +9 -0
- package/out/Shared/classes/LogService.js +37 -0
- package/out/Shared/constants.d.ts +23 -0
- package/out/Shared/constants.js +50 -0
- package/out/Shared/diagnostics.d.ts +79 -0
- package/out/Shared/diagnostics.js +140 -0
- package/out/Shared/errors/DiagnosticError.d.ts +7 -0
- package/out/Shared/errors/DiagnosticError.js +16 -0
- package/out/Shared/errors/LoggableError.d.ts +5 -0
- package/out/Shared/errors/LoggableError.js +14 -0
- package/out/Shared/errors/ProjectError.d.ts +4 -0
- package/out/Shared/errors/ProjectError.js +12 -0
- package/out/Shared/index.d.ts +0 -0
- package/out/Shared/index.js +2 -0
- package/out/Shared/types.d.ts +50 -0
- package/out/Shared/types.js +3 -0
- package/out/Shared/util/assert.d.ts +1 -0
- package/out/Shared/util/assert.js +12 -0
- package/out/Shared/util/benchmark.d.ts +3 -0
- package/out/Shared/util/benchmark.js +32 -0
- package/out/Shared/util/createDiagnosticWithLocation.d.ts +3 -0
- package/out/Shared/util/createDiagnosticWithLocation.js +29 -0
- package/out/Shared/util/createGithubLink.d.ts +1 -0
- package/out/Shared/util/createGithubLink.js +12 -0
- package/out/Shared/util/createTextDiagnostic.d.ts +2 -0
- package/out/Shared/util/createTextDiagnostic.js +18 -0
- package/out/Shared/util/findAncestorDir.d.ts +1 -0
- package/out/Shared/util/findAncestorDir.js +16 -0
- package/out/Shared/util/findLastIndex.d.ts +1 -0
- package/out/Shared/util/findLastIndex.js +12 -0
- package/out/Shared/util/formatDiagnostics.d.ts +2 -0
- package/out/Shared/util/formatDiagnostics.js +19 -0
- package/out/Shared/util/getCanonicalFileName.d.ts +2 -0
- package/out/Shared/util/getCanonicalFileName.js +10 -0
- package/out/Shared/util/getOrSetDefault.d.ts +1 -0
- package/out/Shared/util/getOrSetDefault.js +12 -0
- package/out/Shared/util/getRootDirs.d.ts +2 -0
- package/out/Shared/util/getRootDirs.js +10 -0
- package/out/Shared/util/hasErrors.d.ts +2 -0
- package/out/Shared/util/hasErrors.js +11 -0
- package/out/Shared/util/isPathDescendantOf.d.ts +1 -0
- package/out/Shared/util/isPathDescendantOf.js +11 -0
- package/out/Shared/util/realPathExistsSync.d.ts +1 -0
- package/out/Shared/util/realPathExistsSync.js +13 -0
- package/out/Shared/warn.d.ts +1 -0
- package/out/Shared/warn.js +12 -0
- package/out/TSTransformer/classes/DiagnosticService.d.ts +11 -0
- package/out/TSTransformer/classes/DiagnosticService.js +37 -0
- package/out/TSTransformer/classes/MacroManager.d.ts +46 -0
- package/out/TSTransformer/classes/MacroManager.js +178 -0
- package/out/TSTransformer/classes/MultiTransformState.d.ts +9 -0
- package/out/TSTransformer/classes/MultiTransformState.js +15 -0
- package/out/TSTransformer/classes/TransformState.d.ts +73 -0
- package/out/TSTransformer/classes/TransformState.js +307 -0
- package/out/TSTransformer/index.d.ts +4 -0
- package/out/TSTransformer/index.js +23 -0
- package/out/TSTransformer/macros/callMacros.d.ts +2 -0
- package/out/TSTransformer/macros/callMacros.js +56 -0
- package/out/TSTransformer/macros/constructorMacros.d.ts +2 -0
- package/out/TSTransformer/macros/constructorMacros.js +97 -0
- package/out/TSTransformer/macros/identifierMacros.d.ts +2 -0
- package/out/TSTransformer/macros/identifierMacros.js +7 -0
- package/out/TSTransformer/macros/propertyCallMacros.d.ts +4 -0
- package/out/TSTransformer/macros/propertyCallMacros.js +726 -0
- package/out/TSTransformer/macros/types.d.ts +12 -0
- package/out/TSTransformer/macros/types.js +3 -0
- package/out/TSTransformer/nodes/binding/transformArrayAssignmentPattern.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformArrayAssignmentPattern.js +78 -0
- package/out/TSTransformer/nodes/binding/transformArrayBindingPattern.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformArrayBindingPattern.js +52 -0
- package/out/TSTransformer/nodes/binding/transformBindingName.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformBindingName.js +30 -0
- package/out/TSTransformer/nodes/binding/transformObjectAssignmentPattern.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformObjectAssignmentPattern.js +97 -0
- package/out/TSTransformer/nodes/binding/transformObjectBindingPattern.d.ts +4 -0
- package/out/TSTransformer/nodes/binding/transformObjectBindingPattern.js +57 -0
- package/out/TSTransformer/nodes/class/transformClassConstructor.d.ts +7 -0
- package/out/TSTransformer/nodes/class/transformClassConstructor.js +96 -0
- package/out/TSTransformer/nodes/class/transformClassLikeDeclaration.d.ts +7 -0
- package/out/TSTransformer/nodes/class/transformClassLikeDeclaration.js +262 -0
- package/out/TSTransformer/nodes/class/transformDecorators.d.ts +4 -0
- package/out/TSTransformer/nodes/class/transformDecorators.js +179 -0
- package/out/TSTransformer/nodes/class/transformPropertyDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/class/transformPropertyDeclaration.js +33 -0
- package/out/TSTransformer/nodes/expressions/transformArrayLiteralExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformArrayLiteralExpression.js +79 -0
- package/out/TSTransformer/nodes/expressions/transformAwaitExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformAwaitExpression.js +13 -0
- package/out/TSTransformer/nodes/expressions/transformBinaryExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformBinaryExpression.js +199 -0
- package/out/TSTransformer/nodes/expressions/transformBooleanLiteral.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformBooleanLiteral.js +15 -0
- package/out/TSTransformer/nodes/expressions/transformCallExpression.d.ts +7 -0
- package/out/TSTransformer/nodes/expressions/transformCallExpression.js +191 -0
- package/out/TSTransformer/nodes/expressions/transformClassExpression.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformClassExpression.js +10 -0
- package/out/TSTransformer/nodes/expressions/transformConditionalExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformConditionalExpression.js +55 -0
- package/out/TSTransformer/nodes/expressions/transformDeleteExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformDeleteExpression.js +14 -0
- package/out/TSTransformer/nodes/expressions/transformElementAccessExpression.d.ts +5 -0
- package/out/TSTransformer/nodes/expressions/transformElementAccessExpression.js +62 -0
- package/out/TSTransformer/nodes/expressions/transformExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformExpression.js +107 -0
- package/out/TSTransformer/nodes/expressions/transformFunctionExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformFunctionExpression.js +46 -0
- package/out/TSTransformer/nodes/expressions/transformIdentifier.d.ts +5 -0
- package/out/TSTransformer/nodes/expressions/transformIdentifier.js +147 -0
- package/out/TSTransformer/nodes/expressions/transformImportExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformImportExpression.js +30 -0
- package/out/TSTransformer/nodes/expressions/transformJsxElement.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformJsxElement.js +8 -0
- package/out/TSTransformer/nodes/expressions/transformJsxExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformJsxExpression.js +19 -0
- package/out/TSTransformer/nodes/expressions/transformJsxFragment.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformJsxFragment.js +28 -0
- package/out/TSTransformer/nodes/expressions/transformJsxSelfClosingElement.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformJsxSelfClosingElement.js +8 -0
- package/out/TSTransformer/nodes/expressions/transformNewExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformNewExpression.js +26 -0
- package/out/TSTransformer/nodes/expressions/transformNoSubstitutionTemplateLiteral.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformNoSubstitutionTemplateLiteral.js +14 -0
- package/out/TSTransformer/nodes/expressions/transformNumericLiteral.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformNumericLiteral.js +13 -0
- package/out/TSTransformer/nodes/expressions/transformObjectLiteralExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformObjectLiteralExpression.js +98 -0
- package/out/TSTransformer/nodes/expressions/transformOmittedExpression.d.ts +2 -0
- package/out/TSTransformer/nodes/expressions/transformOmittedExpression.js +11 -0
- package/out/TSTransformer/nodes/expressions/transformParenthesizedExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformParenthesizedExpression.js +19 -0
- package/out/TSTransformer/nodes/expressions/transformPropertyAccessExpression.d.ts +5 -0
- package/out/TSTransformer/nodes/expressions/transformPropertyAccessExpression.js +36 -0
- package/out/TSTransformer/nodes/expressions/transformSpreadElement.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformSpreadElement.js +35 -0
- package/out/TSTransformer/nodes/expressions/transformStringLiteral.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformStringLiteral.js +12 -0
- package/out/TSTransformer/nodes/expressions/transformSuperKeyword.d.ts +2 -0
- package/out/TSTransformer/nodes/expressions/transformSuperKeyword.js +11 -0
- package/out/TSTransformer/nodes/expressions/transformTaggedTemplateExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformTaggedTemplateExpression.js +27 -0
- package/out/TSTransformer/nodes/expressions/transformTemplateExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformTemplateExpression.js +25 -0
- package/out/TSTransformer/nodes/expressions/transformThisExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformThisExpression.js +29 -0
- package/out/TSTransformer/nodes/expressions/transformTypeExpression.d.ts +3 -0
- package/out/TSTransformer/nodes/expressions/transformTypeExpression.js +8 -0
- package/out/TSTransformer/nodes/expressions/transformUnaryExpression.d.ts +5 -0
- package/out/TSTransformer/nodes/expressions/transformUnaryExpression.js +68 -0
- package/out/TSTransformer/nodes/expressions/transformVoidExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformVoidExpression.js +14 -0
- package/out/TSTransformer/nodes/expressions/transformYieldExpression.d.ts +4 -0
- package/out/TSTransformer/nodes/expressions/transformYieldExpression.js +46 -0
- package/out/TSTransformer/nodes/jsx/transformJsx.d.ts +4 -0
- package/out/TSTransformer/nodes/jsx/transformJsx.js +36 -0
- package/out/TSTransformer/nodes/jsx/transformJsxAttributes.d.ts +4 -0
- package/out/TSTransformer/nodes/jsx/transformJsxAttributes.js +83 -0
- package/out/TSTransformer/nodes/jsx/transformJsxChildren.d.ts +4 -0
- package/out/TSTransformer/nodes/jsx/transformJsxChildren.js +34 -0
- package/out/TSTransformer/nodes/jsx/transformJsxTagName.d.ts +4 -0
- package/out/TSTransformer/nodes/jsx/transformJsxTagName.js +42 -0
- package/out/TSTransformer/nodes/statements/transformBlock.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformBlock.js +14 -0
- package/out/TSTransformer/nodes/statements/transformBreakStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformBreakStatement.js +24 -0
- package/out/TSTransformer/nodes/statements/transformClassDeclaration.d.ts +3 -0
- package/out/TSTransformer/nodes/statements/transformClassDeclaration.js +8 -0
- package/out/TSTransformer/nodes/statements/transformContinueStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformContinueStatement.js +24 -0
- package/out/TSTransformer/nodes/statements/transformDoStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformDoStatement.js +31 -0
- package/out/TSTransformer/nodes/statements/transformEnumDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformEnumDeclaration.js +97 -0
- package/out/TSTransformer/nodes/statements/transformExportAssignment.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformExportAssignment.js +53 -0
- package/out/TSTransformer/nodes/statements/transformExportDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformExportDeclaration.js +109 -0
- package/out/TSTransformer/nodes/statements/transformExpressionStatement.d.ts +5 -0
- package/out/TSTransformer/nodes/statements/transformExpressionStatement.js +62 -0
- package/out/TSTransformer/nodes/statements/transformForOfStatement.d.ts +5 -0
- package/out/TSTransformer/nodes/statements/transformForOfStatement.js +375 -0
- package/out/TSTransformer/nodes/statements/transformForStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformForStatement.js +371 -0
- package/out/TSTransformer/nodes/statements/transformFunctionDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformFunctionDeclaration.js +68 -0
- package/out/TSTransformer/nodes/statements/transformIfStatement.d.ts +5 -0
- package/out/TSTransformer/nodes/statements/transformIfStatement.js +46 -0
- package/out/TSTransformer/nodes/statements/transformImportDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformImportDeclaration.js +98 -0
- package/out/TSTransformer/nodes/statements/transformImportEqualsDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformImportEqualsDeclaration.js +36 -0
- package/out/TSTransformer/nodes/statements/transformModuleDeclaration.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformModuleDeclaration.js +122 -0
- package/out/TSTransformer/nodes/statements/transformReturnStatement.d.ts +5 -0
- package/out/TSTransformer/nodes/statements/transformReturnStatement.js +74 -0
- package/out/TSTransformer/nodes/statements/transformStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformStatement.js +83 -0
- package/out/TSTransformer/nodes/statements/transformSwitchStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformSwitchStatement.js +105 -0
- package/out/TSTransformer/nodes/statements/transformThrowStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformThrowStatement.js +18 -0
- package/out/TSTransformer/nodes/statements/transformTryStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformTryStatement.js +148 -0
- package/out/TSTransformer/nodes/statements/transformVariableStatement.d.ts +8 -0
- package/out/TSTransformer/nodes/statements/transformVariableStatement.js +155 -0
- package/out/TSTransformer/nodes/statements/transformWhileStatement.d.ts +4 -0
- package/out/TSTransformer/nodes/statements/transformWhileStatement.js +30 -0
- package/out/TSTransformer/nodes/transformEntityName.d.ts +4 -0
- package/out/TSTransformer/nodes/transformEntityName.js +24 -0
- package/out/TSTransformer/nodes/transformInitializer.d.ts +4 -0
- package/out/TSTransformer/nodes/transformInitializer.js +22 -0
- package/out/TSTransformer/nodes/transformInterpolatedStringPart.d.ts +3 -0
- package/out/TSTransformer/nodes/transformInterpolatedStringPart.js +12 -0
- package/out/TSTransformer/nodes/transformLogical.d.ts +4 -0
- package/out/TSTransformer/nodes/transformLogical.js +103 -0
- package/out/TSTransformer/nodes/transformLogicalOrCoalescingAssignmentExpression.d.ts +5 -0
- package/out/TSTransformer/nodes/transformLogicalOrCoalescingAssignmentExpression.js +91 -0
- package/out/TSTransformer/nodes/transformMethodDeclaration.d.ts +5 -0
- package/out/TSTransformer/nodes/transformMethodDeclaration.js +82 -0
- package/out/TSTransformer/nodes/transformOptionalChain.d.ts +46 -0
- package/out/TSTransformer/nodes/transformOptionalChain.js +257 -0
- package/out/TSTransformer/nodes/transformParameters.d.ts +8 -0
- package/out/TSTransformer/nodes/transformParameters.js +104 -0
- package/out/TSTransformer/nodes/transformPropertyName.d.ts +4 -0
- package/out/TSTransformer/nodes/transformPropertyName.js +18 -0
- package/out/TSTransformer/nodes/transformSourceFile.d.ts +4 -0
- package/out/TSTransformer/nodes/transformSourceFile.js +171 -0
- package/out/TSTransformer/nodes/transformStatementList.d.ts +7 -0
- package/out/TSTransformer/nodes/transformStatementList.js +63 -0
- package/out/TSTransformer/nodes/transformWritable.d.ts +9 -0
- package/out/TSTransformer/nodes/transformWritable.js +49 -0
- package/out/TSTransformer/typeGuards.d.ts +5 -0
- package/out/TSTransformer/typeGuards.js +27 -0
- package/out/TSTransformer/types.d.ts +9 -0
- package/out/TSTransformer/types.js +3 -0
- package/out/TSTransformer/util/addIndexDiagnostics.d.ts +3 -0
- package/out/TSTransformer/util/addIndexDiagnostics.js +24 -0
- package/out/TSTransformer/util/addOneIfArrayType.d.ts +4 -0
- package/out/TSTransformer/util/addOneIfArrayType.js +14 -0
- package/out/TSTransformer/util/arrayBindingPatternContainsHoists.d.ts +3 -0
- package/out/TSTransformer/util/arrayBindingPatternContainsHoists.js +23 -0
- package/out/TSTransformer/util/arrayLikeExpressionContainsSpread.d.ts +2 -0
- package/out/TSTransformer/util/arrayLikeExpressionContainsSpread.js +17 -0
- package/out/TSTransformer/util/assertNever.d.ts +1 -0
- package/out/TSTransformer/util/assertNever.js +36 -0
- package/out/TSTransformer/util/assignment.d.ts +7 -0
- package/out/TSTransformer/util/assignment.js +48 -0
- package/out/TSTransformer/util/binding/getAccessorForBindingType.d.ts +6 -0
- package/out/TSTransformer/util/binding/getAccessorForBindingType.js +141 -0
- package/out/TSTransformer/util/binding/getTargetIdForBindingPattern.d.ts +4 -0
- package/out/TSTransformer/util/binding/getTargetIdForBindingPattern.js +15 -0
- package/out/TSTransformer/util/binding/objectAccessor.d.ts +4 -0
- package/out/TSTransformer/util/binding/objectAccessor.js +39 -0
- package/out/TSTransformer/util/bitwise.d.ts +6 -0
- package/out/TSTransformer/util/bitwise.js +67 -0
- package/out/TSTransformer/util/checkVariableHoist.d.ts +3 -0
- package/out/TSTransformer/util/checkVariableHoist.js +33 -0
- package/out/TSTransformer/util/cleanModuleName.d.ts +1 -0
- package/out/TSTransformer/util/cleanModuleName.js +7 -0
- package/out/TSTransformer/util/convertToIndexableExpression.d.ts +3 -0
- package/out/TSTransformer/util/convertToIndexableExpression.js +14 -0
- package/out/TSTransformer/util/createBinaryFromOperator.d.ts +4 -0
- package/out/TSTransformer/util/createBinaryFromOperator.js +54 -0
- package/out/TSTransformer/util/createGetService.d.ts +2 -0
- package/out/TSTransformer/util/createGetService.js +15 -0
- package/out/TSTransformer/util/createHoistDeclaration.d.ts +4 -0
- package/out/TSTransformer/util/createHoistDeclaration.js +20 -0
- package/out/TSTransformer/util/createImportExpression.d.ts +5 -0
- package/out/TSTransformer/util/createImportExpression.js +181 -0
- package/out/TSTransformer/util/createStringFromLiteral.d.ts +2 -0
- package/out/TSTransformer/util/createStringFromLiteral.js +27 -0
- package/out/TSTransformer/util/createTransformServices.d.ts +3 -0
- package/out/TSTransformer/util/createTransformServices.js +9 -0
- package/out/TSTransformer/util/createTruthinessChecks.d.ts +5 -0
- package/out/TSTransformer/util/createTruthinessChecks.js +50 -0
- package/out/TSTransformer/util/createTypeCheck.d.ts +2 -0
- package/out/TSTransformer/util/createTypeCheck.js +11 -0
- package/out/TSTransformer/util/ensureTransformOrder.d.ts +5 -0
- package/out/TSTransformer/util/ensureTransformOrder.js +39 -0
- package/out/TSTransformer/util/expressionChain.d.ts +3 -0
- package/out/TSTransformer/util/expressionChain.js +16 -0
- package/out/TSTransformer/util/expressionMightMutate.d.ts +4 -0
- package/out/TSTransformer/util/expressionMightMutate.js +57 -0
- package/out/TSTransformer/util/findConstructor.d.ts +4 -0
- package/out/TSTransformer/util/findConstructor.js +11 -0
- package/out/TSTransformer/util/fixupWhitespaceAndDecodeEntities.d.ts +1 -0
- package/out/TSTransformer/util/fixupWhitespaceAndDecodeEntities.js +306 -0
- package/out/TSTransformer/util/getAddIterableToArrayBuilder.d.ts +6 -0
- package/out/TSTransformer/util/getAddIterableToArrayBuilder.js +253 -0
- package/out/TSTransformer/util/getAssignableValue.d.ts +3 -0
- package/out/TSTransformer/util/getAssignableValue.js +15 -0
- package/out/TSTransformer/util/getConstantValueLiteral.d.ts +4 -0
- package/out/TSTransformer/util/getConstantValueLiteral.js +19 -0
- package/out/TSTransformer/util/getDeclaredVariables.d.ts +2 -0
- package/out/TSTransformer/util/getDeclaredVariables.js +37 -0
- package/out/TSTransformer/util/getExtendsNode.d.ts +2 -0
- package/out/TSTransformer/util/getExtendsNode.js +16 -0
- package/out/TSTransformer/util/getFlags.d.ts +1 -0
- package/out/TSTransformer/util/getFlags.js +13 -0
- package/out/TSTransformer/util/getKindName.d.ts +2 -0
- package/out/TSTransformer/util/getKindName.js +61 -0
- package/out/TSTransformer/util/getOriginalSymbolOfNode.d.ts +2 -0
- package/out/TSTransformer/util/getOriginalSymbolOfNode.js +15 -0
- package/out/TSTransformer/util/getSourceFileFromModuleSpecifier.d.ts +3 -0
- package/out/TSTransformer/util/getSourceFileFromModuleSpecifier.js +33 -0
- package/out/TSTransformer/util/getStatements.d.ts +2 -0
- package/out/TSTransformer/util/getStatements.js +11 -0
- package/out/TSTransformer/util/hasMultipleDefinitions.d.ts +2 -0
- package/out/TSTransformer/util/hasMultipleDefinitions.js +17 -0
- package/out/TSTransformer/util/isBlockedByTryStatement.d.ts +3 -0
- package/out/TSTransformer/util/isBlockedByTryStatement.js +17 -0
- package/out/TSTransformer/util/isMethod.d.ts +4 -0
- package/out/TSTransformer/util/isMethod.js +90 -0
- package/out/TSTransformer/util/isSymbolMutable.d.ts +3 -0
- package/out/TSTransformer/util/isSymbolMutable.js +24 -0
- package/out/TSTransformer/util/isSymbolOfValue.d.ts +2 -0
- package/out/TSTransformer/util/isSymbolOfValue.js +11 -0
- package/out/TSTransformer/util/isUsedAsStatement.d.ts +2 -0
- package/out/TSTransformer/util/isUsedAsStatement.js +23 -0
- package/out/TSTransformer/util/isValidMethodIndexWithoutCall.d.ts +3 -0
- package/out/TSTransformer/util/isValidMethodIndexWithoutCall.js +31 -0
- package/out/TSTransformer/util/offset.d.ts +2 -0
- package/out/TSTransformer/util/offset.js +44 -0
- package/out/TSTransformer/util/pointer.d.ts +13 -0
- package/out/TSTransformer/util/pointer.js +46 -0
- package/out/TSTransformer/util/spreadDestructuring/index.d.ts +9 -0
- package/out/TSTransformer/util/spreadDestructuring/index.js +45 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureArray.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureArray.js +17 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureGenerator.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureGenerator.js +33 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureMap.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureMap.js +34 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureObject.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureObject.js +41 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureSet.d.ts +3 -0
- package/out/TSTransformer/util/spreadDestructuring/spreadDestructureSet.js +28 -0
- package/out/TSTransformer/util/traversal.d.ts +7 -0
- package/out/TSTransformer/util/traversal.js +57 -0
- package/out/TSTransformer/util/types.d.ts +31 -0
- package/out/TSTransformer/util/types.js +259 -0
- package/out/TSTransformer/util/validateIdentifier.d.ts +3 -0
- package/out/TSTransformer/util/validateIdentifier.js +18 -0
- package/out/TSTransformer/util/validateMethodAssignment.d.ts +3 -0
- package/out/TSTransformer/util/validateMethodAssignment.js +81 -0
- package/out/TSTransformer/util/validateNotAny.d.ts +3 -0
- package/out/TSTransformer/util/validateNotAny.js +37 -0
- package/out/TSTransformer/util/valueToIdStr.d.ts +2 -0
- package/out/TSTransformer/util/valueToIdStr.js +29 -0
- package/out/TSTransformer/util/wrapExpressionStatement.d.ts +2 -0
- package/out/TSTransformer/util/wrapExpressionStatement.js +22 -0
- package/out/TSTransformer/util/wrapReturnIfLuaTuple.d.ts +4 -0
- package/out/TSTransformer/util/wrapReturnIfLuaTuple.js +56 -0
- package/out/TSTransformer/util/wrapStatementsAsGenerator.d.ts +4 -0
- package/out/TSTransformer/util/wrapStatementsAsGenerator.js +19 -0
- package/package.json +72 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.flattenOptionalChain = flattenOptionalChain;
|
|
7
|
+
exports.transformOptionalChain = transformOptionalChain;
|
|
8
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
9
|
+
const diagnostics_1 = require("../../Shared/diagnostics");
|
|
10
|
+
const DiagnosticService_1 = require("../classes/DiagnosticService");
|
|
11
|
+
const transformCallExpression_1 = require("./expressions/transformCallExpression");
|
|
12
|
+
const transformElementAccessExpression_1 = require("./expressions/transformElementAccessExpression");
|
|
13
|
+
const transformExpression_1 = require("./expressions/transformExpression");
|
|
14
|
+
const transformPropertyAccessExpression_1 = require("./expressions/transformPropertyAccessExpression");
|
|
15
|
+
const addOneIfArrayType_1 = require("../util/addOneIfArrayType");
|
|
16
|
+
const convertToIndexableExpression_1 = require("../util/convertToIndexableExpression");
|
|
17
|
+
const ensureTransformOrder_1 = require("../util/ensureTransformOrder");
|
|
18
|
+
const isMethod_1 = require("../util/isMethod");
|
|
19
|
+
const isUsedAsStatement_1 = require("../util/isUsedAsStatement");
|
|
20
|
+
const traversal_1 = require("../util/traversal");
|
|
21
|
+
const types_1 = require("../util/types");
|
|
22
|
+
const wrapReturnIfLuaTuple_1 = require("../util/wrapReturnIfLuaTuple");
|
|
23
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
24
|
+
var OptionalChainItemKind;
|
|
25
|
+
(function (OptionalChainItemKind) {
|
|
26
|
+
OptionalChainItemKind[OptionalChainItemKind["PropertyAccess"] = 0] = "PropertyAccess";
|
|
27
|
+
OptionalChainItemKind[OptionalChainItemKind["ElementAccess"] = 1] = "ElementAccess";
|
|
28
|
+
OptionalChainItemKind[OptionalChainItemKind["Call"] = 2] = "Call";
|
|
29
|
+
OptionalChainItemKind[OptionalChainItemKind["PropertyCall"] = 3] = "PropertyCall";
|
|
30
|
+
OptionalChainItemKind[OptionalChainItemKind["ElementCall"] = 4] = "ElementCall";
|
|
31
|
+
})(OptionalChainItemKind || (OptionalChainItemKind = {}));
|
|
32
|
+
function createPropertyAccessItem(state, node) {
|
|
33
|
+
return {
|
|
34
|
+
node,
|
|
35
|
+
kind: OptionalChainItemKind.PropertyAccess,
|
|
36
|
+
optional: node.questionDotToken !== undefined,
|
|
37
|
+
type: state.getType(node.expression),
|
|
38
|
+
name: node.name.text,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function createElementAccessItem(state, node) {
|
|
42
|
+
return {
|
|
43
|
+
node,
|
|
44
|
+
kind: OptionalChainItemKind.ElementAccess,
|
|
45
|
+
optional: node.questionDotToken !== undefined,
|
|
46
|
+
type: state.getType(node.expression),
|
|
47
|
+
expression: node.argumentExpression,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function createCallItem(state, node) {
|
|
51
|
+
return {
|
|
52
|
+
node,
|
|
53
|
+
kind: OptionalChainItemKind.Call,
|
|
54
|
+
optional: node.questionDotToken !== undefined,
|
|
55
|
+
type: state.getType(node.expression),
|
|
56
|
+
args: node.arguments,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function createPropertyCallItem(state, node, expression) {
|
|
60
|
+
return {
|
|
61
|
+
node,
|
|
62
|
+
expression,
|
|
63
|
+
kind: OptionalChainItemKind.PropertyCall,
|
|
64
|
+
optional: expression.questionDotToken !== undefined,
|
|
65
|
+
type: state.getType(node.expression),
|
|
66
|
+
name: expression.name.text,
|
|
67
|
+
callType: state.getType(node),
|
|
68
|
+
callOptional: node.questionDotToken !== undefined,
|
|
69
|
+
args: node.arguments,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function createElementCallItem(state, node, expression) {
|
|
73
|
+
return {
|
|
74
|
+
node,
|
|
75
|
+
expression,
|
|
76
|
+
kind: OptionalChainItemKind.ElementCall,
|
|
77
|
+
optional: expression.questionDotToken !== undefined,
|
|
78
|
+
type: state.getType(expression),
|
|
79
|
+
argumentExpression: expression.argumentExpression,
|
|
80
|
+
callType: state.getType(node),
|
|
81
|
+
callOptional: node.questionDotToken !== undefined,
|
|
82
|
+
args: node.arguments,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function flattenOptionalChain(state, expression) {
|
|
86
|
+
const chain = new Array();
|
|
87
|
+
while (true) {
|
|
88
|
+
if (typescript_1.default.isPropertyAccessExpression(expression)) {
|
|
89
|
+
chain.unshift(createPropertyAccessItem(state, expression));
|
|
90
|
+
expression = expression.expression;
|
|
91
|
+
}
|
|
92
|
+
else if (typescript_1.default.isElementAccessExpression(expression)) {
|
|
93
|
+
chain.unshift(createElementAccessItem(state, expression));
|
|
94
|
+
expression = expression.expression;
|
|
95
|
+
}
|
|
96
|
+
else if (typescript_1.default.isCallExpression(expression)) {
|
|
97
|
+
const subExp = (0, traversal_1.skipDownwards)(expression.expression);
|
|
98
|
+
if (typescript_1.default.isPropertyAccessExpression(subExp)) {
|
|
99
|
+
chain.unshift(createPropertyCallItem(state, expression, subExp));
|
|
100
|
+
expression = subExp.expression;
|
|
101
|
+
}
|
|
102
|
+
else if (typescript_1.default.isElementAccessExpression(subExp)) {
|
|
103
|
+
chain.unshift(createElementCallItem(state, expression, subExp));
|
|
104
|
+
expression = subExp.expression;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
chain.unshift(createCallItem(state, expression));
|
|
108
|
+
expression = subExp;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { chain, expression };
|
|
116
|
+
}
|
|
117
|
+
function transformChainItem(state, baseExpression, item) {
|
|
118
|
+
if (item.kind === OptionalChainItemKind.PropertyAccess) {
|
|
119
|
+
return (0, transformPropertyAccessExpression_1.transformPropertyAccessExpressionInner)(state, item.node, baseExpression, item.name);
|
|
120
|
+
}
|
|
121
|
+
else if (item.kind === OptionalChainItemKind.ElementAccess) {
|
|
122
|
+
return (0, transformElementAccessExpression_1.transformElementAccessExpressionInner)(state, item.node, baseExpression, item.expression);
|
|
123
|
+
}
|
|
124
|
+
else if (item.kind === OptionalChainItemKind.Call) {
|
|
125
|
+
return (0, transformCallExpression_1.transformCallExpressionInner)(state, item.node, baseExpression, item.args);
|
|
126
|
+
}
|
|
127
|
+
else if (item.kind === OptionalChainItemKind.PropertyCall) {
|
|
128
|
+
return (0, transformCallExpression_1.transformPropertyCallExpressionInner)(state, item.node, item.expression, baseExpression, item.name, item.args);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
return (0, transformCallExpression_1.transformElementCallExpressionInner)(state, item.node, item.expression, baseExpression, item.argumentExpression, item.args);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function createOrSetTempId(state, tempId, expression, node) {
|
|
135
|
+
if (tempId === undefined) {
|
|
136
|
+
tempId = state.pushToVar(expression, node.parent && typescript_1.default.isVariableDeclaration(node.parent) && typescript_1.default.isIdentifier(node.parent.name)
|
|
137
|
+
? node.parent.name.text
|
|
138
|
+
: "result");
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
if (tempId !== expression) {
|
|
142
|
+
state.prereq(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Assignment, {
|
|
143
|
+
left: tempId,
|
|
144
|
+
operator: "=",
|
|
145
|
+
right: expression,
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return tempId;
|
|
150
|
+
}
|
|
151
|
+
function createNilCheck(tempId, statements) {
|
|
152
|
+
return luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.IfStatement, {
|
|
153
|
+
condition: luau_ast_1.default.binary(tempId, "~=", luau_ast_1.default.nil()),
|
|
154
|
+
statements,
|
|
155
|
+
elseBody: luau_ast_1.default.list.make(),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function isCompoundCall(item) {
|
|
159
|
+
return item.kind === OptionalChainItemKind.PropertyCall || item.kind === OptionalChainItemKind.ElementCall;
|
|
160
|
+
}
|
|
161
|
+
function transformOptionalChainInner(state, chain, baseExpression, tempId = undefined, index = 0) {
|
|
162
|
+
if (index >= chain.length)
|
|
163
|
+
return baseExpression;
|
|
164
|
+
const item = chain[index];
|
|
165
|
+
if (item.optional || (isCompoundCall(item) && item.callOptional)) {
|
|
166
|
+
let isMethodCall = false;
|
|
167
|
+
let isSuperCall = false;
|
|
168
|
+
let selfParam;
|
|
169
|
+
if (isCompoundCall(item)) {
|
|
170
|
+
isMethodCall = (0, isMethod_1.isMethod)(state, item.expression);
|
|
171
|
+
isSuperCall = typescript_1.default.isSuperProperty(item.expression);
|
|
172
|
+
if (item.callOptional && isMethodCall && !isSuperCall) {
|
|
173
|
+
selfParam = state.pushToVar(baseExpression, "self");
|
|
174
|
+
baseExpression = selfParam;
|
|
175
|
+
}
|
|
176
|
+
if (item.optional) {
|
|
177
|
+
tempId = createOrSetTempId(state, tempId, baseExpression, chain[chain.length - 1].node);
|
|
178
|
+
baseExpression = tempId;
|
|
179
|
+
}
|
|
180
|
+
if (item.callOptional) {
|
|
181
|
+
if (item.kind === OptionalChainItemKind.PropertyCall) {
|
|
182
|
+
baseExpression = luau_ast_1.default.property((0, convertToIndexableExpression_1.convertToIndexableExpression)(baseExpression), item.name);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
const expType = state.getType(item.expression.expression);
|
|
186
|
+
baseExpression = luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ComputedIndexExpression, {
|
|
187
|
+
expression: (0, convertToIndexableExpression_1.convertToIndexableExpression)(baseExpression),
|
|
188
|
+
index: (0, addOneIfArrayType_1.addOneIfArrayType)(state, expType, (0, transformExpression_1.transformExpression)(state, item.argumentExpression)),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const [result, prereqStatements] = state.capture(() => {
|
|
194
|
+
tempId = createOrSetTempId(state, tempId, baseExpression, chain[chain.length - 1].node);
|
|
195
|
+
const [newValue, ifStatements] = state.capture(() => {
|
|
196
|
+
let newExpression;
|
|
197
|
+
if (isCompoundCall(item) && item.callOptional) {
|
|
198
|
+
const expType = state.typeChecker.getNonOptionalType(state.getType(item.node.expression));
|
|
199
|
+
const symbol = (0, types_1.getFirstDefinedSymbol)(state, expType);
|
|
200
|
+
if (symbol) {
|
|
201
|
+
const macro = state.services.macroManager.getPropertyCallMacro(symbol);
|
|
202
|
+
if (macro) {
|
|
203
|
+
DiagnosticService_1.DiagnosticService.addDiagnostic(diagnostics_1.errors.noOptionalMacroCall(item.node));
|
|
204
|
+
return luau_ast_1.default.none();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const args = (0, ensureTransformOrder_1.ensureTransformOrder)(state, item.args);
|
|
208
|
+
if (isMethodCall) {
|
|
209
|
+
if (isSuperCall) {
|
|
210
|
+
args.unshift(luau_ast_1.default.globals.self);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
args.unshift(selfParam);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
newExpression = (0, wrapReturnIfLuaTuple_1.wrapReturnIfLuaTuple)(state, item.node, luau_ast_1.default.call(tempId, args));
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
newExpression = transformChainItem(state, tempId, item);
|
|
220
|
+
}
|
|
221
|
+
return transformOptionalChainInner(state, chain, newExpression, tempId, index + 1);
|
|
222
|
+
});
|
|
223
|
+
const isUsed = !luau_ast_1.default.isNone(newValue) && !(0, isUsedAsStatement_1.isUsedAsStatement)(item.node);
|
|
224
|
+
if (tempId !== newValue && isUsed) {
|
|
225
|
+
luau_ast_1.default.list.push(ifStatements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Assignment, {
|
|
226
|
+
left: tempId,
|
|
227
|
+
operator: "=",
|
|
228
|
+
right: newValue,
|
|
229
|
+
}));
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
if (luau_ast_1.default.isCall(newValue)) {
|
|
233
|
+
luau_ast_1.default.list.push(ifStatements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.CallStatement, {
|
|
234
|
+
expression: newValue,
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
state.prereq(createNilCheck(tempId, ifStatements));
|
|
239
|
+
return isUsed ? tempId : luau_ast_1.default.none();
|
|
240
|
+
});
|
|
241
|
+
if (isCompoundCall(item) && item.optional && item.callOptional) {
|
|
242
|
+
state.prereq(createNilCheck(tempId, prereqStatements));
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
state.prereqList(prereqStatements);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
return transformOptionalChainInner(state, chain, transformChainItem(state, baseExpression, item), tempId, index + 1);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function transformOptionalChain(state, node) {
|
|
254
|
+
const { chain, expression } = flattenOptionalChain(state, node);
|
|
255
|
+
return transformOptionalChainInner(state, chain, (0, transformExpression_1.transformExpression)(state, expression));
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=transformOptionalChain.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import luau from "@roblox-ts/luau-ast";
|
|
2
|
+
import { TransformState } from "..";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
export declare function transformParameters(state: TransformState, node: ts.SignatureDeclarationBase): {
|
|
5
|
+
parameters: luau.List<luau.AnyIdentifier>;
|
|
6
|
+
statements: luau.List<luau.Statement<luau.SyntaxKind>>;
|
|
7
|
+
hasDotDotDot: boolean;
|
|
8
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformParameters = transformParameters;
|
|
7
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
8
|
+
const transformArrayBindingPattern_1 = require("./binding/transformArrayBindingPattern");
|
|
9
|
+
const transformObjectBindingPattern_1 = require("./binding/transformObjectBindingPattern");
|
|
10
|
+
const transformIdentifier_1 = require("./expressions/transformIdentifier");
|
|
11
|
+
const transformInitializer_1 = require("./transformInitializer");
|
|
12
|
+
const arrayLikeExpressionContainsSpread_1 = require("../util/arrayLikeExpressionContainsSpread");
|
|
13
|
+
const isMethod_1 = require("../util/isMethod");
|
|
14
|
+
const validateIdentifier_1 = require("../util/validateIdentifier");
|
|
15
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
16
|
+
function optimizeArraySpreadParameter(state, parameters, bindingPattern) {
|
|
17
|
+
for (const element of bindingPattern.elements) {
|
|
18
|
+
if (typescript_1.default.isOmittedExpression(element)) {
|
|
19
|
+
luau_ast_1.default.list.push(parameters, luau_ast_1.default.tempId());
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const name = element.name;
|
|
23
|
+
if (typescript_1.default.isIdentifier(name)) {
|
|
24
|
+
const paramId = (0, transformIdentifier_1.transformIdentifierDefined)(state, name);
|
|
25
|
+
(0, validateIdentifier_1.validateIdentifier)(state, name);
|
|
26
|
+
luau_ast_1.default.list.push(parameters, paramId);
|
|
27
|
+
if (element.initializer) {
|
|
28
|
+
state.prereq((0, transformInitializer_1.transformInitializer)(state, paramId, element.initializer));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const paramId = luau_ast_1.default.tempId("param");
|
|
33
|
+
luau_ast_1.default.list.push(parameters, paramId);
|
|
34
|
+
if (element.initializer) {
|
|
35
|
+
state.prereq((0, transformInitializer_1.transformInitializer)(state, paramId, element.initializer));
|
|
36
|
+
}
|
|
37
|
+
if (typescript_1.default.isArrayBindingPattern(name)) {
|
|
38
|
+
(0, transformArrayBindingPattern_1.transformArrayBindingPattern)(state, name, paramId);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
(0, transformObjectBindingPattern_1.transformObjectBindingPattern)(state, name, paramId);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function transformParameters(state, node) {
|
|
48
|
+
const parameters = luau_ast_1.default.list.make();
|
|
49
|
+
const statements = luau_ast_1.default.list.make();
|
|
50
|
+
let hasDotDotDot = false;
|
|
51
|
+
if ((0, isMethod_1.isMethod)(state, node)) {
|
|
52
|
+
luau_ast_1.default.list.push(parameters, luau_ast_1.default.globals.self);
|
|
53
|
+
}
|
|
54
|
+
for (const parameter of node.parameters) {
|
|
55
|
+
if (typescript_1.default.isThisIdentifier(parameter.name)) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (parameter.dotDotDotToken &&
|
|
59
|
+
typescript_1.default.isArrayBindingPattern(parameter.name) &&
|
|
60
|
+
!(0, arrayLikeExpressionContainsSpread_1.arrayLikeExpressionContainsSpread)(parameter.name)) {
|
|
61
|
+
const prereqs = state.capturePrereqs(() => optimizeArraySpreadParameter(state, parameters, parameter.name));
|
|
62
|
+
luau_ast_1.default.list.pushList(statements, prereqs);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
let paramId;
|
|
66
|
+
if (typescript_1.default.isIdentifier(parameter.name)) {
|
|
67
|
+
paramId = (0, transformIdentifier_1.transformIdentifierDefined)(state, parameter.name);
|
|
68
|
+
(0, validateIdentifier_1.validateIdentifier)(state, parameter.name);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
paramId = luau_ast_1.default.tempId("param");
|
|
72
|
+
}
|
|
73
|
+
if (parameter.dotDotDotToken) {
|
|
74
|
+
hasDotDotDot = true;
|
|
75
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.VariableDeclaration, {
|
|
76
|
+
left: paramId,
|
|
77
|
+
right: luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Array, {
|
|
78
|
+
members: luau_ast_1.default.list.make(luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.VarArgsLiteral, {})),
|
|
79
|
+
}),
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
luau_ast_1.default.list.push(parameters, paramId);
|
|
84
|
+
}
|
|
85
|
+
if (parameter.initializer) {
|
|
86
|
+
luau_ast_1.default.list.push(statements, (0, transformInitializer_1.transformInitializer)(state, paramId, parameter.initializer));
|
|
87
|
+
}
|
|
88
|
+
if (!typescript_1.default.isIdentifier(parameter.name)) {
|
|
89
|
+
const bindingPattern = parameter.name;
|
|
90
|
+
if (typescript_1.default.isArrayBindingPattern(bindingPattern)) {
|
|
91
|
+
luau_ast_1.default.list.pushList(statements, state.capturePrereqs(() => (0, transformArrayBindingPattern_1.transformArrayBindingPattern)(state, bindingPattern, paramId)));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
luau_ast_1.default.list.pushList(statements, state.capturePrereqs(() => (0, transformObjectBindingPattern_1.transformObjectBindingPattern)(state, bindingPattern, paramId)));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
parameters,
|
|
100
|
+
statements,
|
|
101
|
+
hasDotDotDot,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=transformParameters.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformPropertyName = transformPropertyName;
|
|
7
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
8
|
+
const transformExpression_1 = require("./expressions/transformExpression");
|
|
9
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
10
|
+
function transformPropertyName(state, name) {
|
|
11
|
+
if (typescript_1.default.isIdentifier(name)) {
|
|
12
|
+
return luau_ast_1.default.string(name.text);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return (0, transformExpression_1.transformExpression)(state, typescript_1.default.isComputedPropertyName(name) ? name.expression : name);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=transformPropertyName.js.map
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformSourceFile = transformSourceFile;
|
|
7
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
8
|
+
const rojo_resolver_1 = require("@roblox-ts/rojo-resolver");
|
|
9
|
+
const constants_1 = require("../../Shared/constants");
|
|
10
|
+
const assert_1 = require("../../Shared/util/assert");
|
|
11
|
+
const transformIdentifier_1 = require("./expressions/transformIdentifier");
|
|
12
|
+
const transformStatementList_1 = require("./transformStatementList");
|
|
13
|
+
const getOriginalSymbolOfNode_1 = require("../util/getOriginalSymbolOfNode");
|
|
14
|
+
const isSymbolMutable_1 = require("../util/isSymbolMutable");
|
|
15
|
+
const isSymbolOfValue_1 = require("../util/isSymbolOfValue");
|
|
16
|
+
const traversal_1 = require("../util/traversal");
|
|
17
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
18
|
+
function getExportPair(state, exportSymbol) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const declaration = (_a = exportSymbol.getDeclarations()) === null || _a === void 0 ? void 0 : _a[0];
|
|
21
|
+
if (declaration && typescript_1.default.isExportSpecifier(declaration)) {
|
|
22
|
+
return [declaration.name.text, (0, transformIdentifier_1.transformIdentifierDefined)(state, (_b = declaration.propertyName) !== null && _b !== void 0 ? _b : declaration.name)];
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
let name = exportSymbol.name;
|
|
26
|
+
if (exportSymbol.name === "default" &&
|
|
27
|
+
declaration &&
|
|
28
|
+
(typescript_1.default.isFunctionDeclaration(declaration) || typescript_1.default.isClassDeclaration(declaration)) &&
|
|
29
|
+
declaration.name) {
|
|
30
|
+
name = declaration.name.text;
|
|
31
|
+
}
|
|
32
|
+
return [exportSymbol.name, luau_ast_1.default.id(name)];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function isExportSymbolFromExportFrom(exportSymbol) {
|
|
36
|
+
if (exportSymbol.declarations) {
|
|
37
|
+
for (const exportSpecifier of exportSymbol.declarations) {
|
|
38
|
+
if (typescript_1.default.isExportSpecifier(exportSpecifier)) {
|
|
39
|
+
const exportDec = exportSpecifier.parent.parent;
|
|
40
|
+
if (typescript_1.default.isExportDeclaration(exportDec) && exportDec.moduleSpecifier) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
function getIgnoredExportSymbols(state, sourceFile) {
|
|
49
|
+
const ignoredSymbols = new Set();
|
|
50
|
+
for (const statement of sourceFile.statements) {
|
|
51
|
+
if (typescript_1.default.isExportDeclaration(statement) && statement.moduleSpecifier) {
|
|
52
|
+
if (!statement.exportClause) {
|
|
53
|
+
const moduleSymbol = (0, getOriginalSymbolOfNode_1.getOriginalSymbolOfNode)(state.typeChecker, statement.moduleSpecifier);
|
|
54
|
+
if (moduleSymbol) {
|
|
55
|
+
state.getModuleExports(moduleSymbol).forEach(v => ignoredSymbols.add(v));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (typescript_1.default.isNamespaceExport(statement.exportClause)) {
|
|
59
|
+
const idSymbol = state.typeChecker.getSymbolAtLocation(statement.exportClause.name);
|
|
60
|
+
if (idSymbol) {
|
|
61
|
+
ignoredSymbols.add(idSymbol);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return ignoredSymbols;
|
|
67
|
+
}
|
|
68
|
+
function isExportSymbolOnlyFromDeclare(exportSymbol) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
return ((_b = (_a = exportSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(declaration => {
|
|
71
|
+
const statement = (0, traversal_1.getAncestor)(declaration, typescript_1.default.isStatement);
|
|
72
|
+
const modifiers = statement && typescript_1.default.canHaveModifiers(statement) ? typescript_1.default.getModifiers(statement) : undefined;
|
|
73
|
+
return modifiers === null || modifiers === void 0 ? void 0 : modifiers.some(v => v.kind === typescript_1.default.SyntaxKind.DeclareKeyword);
|
|
74
|
+
})) !== null && _b !== void 0 ? _b : false);
|
|
75
|
+
}
|
|
76
|
+
function handleExports(state, sourceFile, symbol, statements) {
|
|
77
|
+
const ignoredExportSymbols = getIgnoredExportSymbols(state, sourceFile);
|
|
78
|
+
let mustPushExports = state.hasExportFrom;
|
|
79
|
+
const exportPairs = new Array();
|
|
80
|
+
if (!state.hasExportEquals) {
|
|
81
|
+
for (const exportSymbol of state.getModuleExports(symbol)) {
|
|
82
|
+
if (ignoredExportSymbols.has(exportSymbol))
|
|
83
|
+
continue;
|
|
84
|
+
if (!!(exportSymbol.flags & typescript_1.default.SymbolFlags.Prototype))
|
|
85
|
+
continue;
|
|
86
|
+
if (isExportSymbolFromExportFrom(exportSymbol))
|
|
87
|
+
continue;
|
|
88
|
+
const originalSymbol = typescript_1.default.skipAlias(exportSymbol, state.typeChecker);
|
|
89
|
+
if (!(0, isSymbolOfValue_1.isSymbolOfValue)(originalSymbol))
|
|
90
|
+
continue;
|
|
91
|
+
if ((0, isSymbolMutable_1.isSymbolMutable)(state, originalSymbol)) {
|
|
92
|
+
mustPushExports = true;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (isExportSymbolOnlyFromDeclare(exportSymbol))
|
|
96
|
+
continue;
|
|
97
|
+
exportPairs.push(getExportPair(state, exportSymbol));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (state.hasExportEquals) {
|
|
101
|
+
const finalStatement = sourceFile.statements[sourceFile.statements.length - 1];
|
|
102
|
+
if (!(typescript_1.default.isExportAssignment(finalStatement) && finalStatement.isExportEquals)) {
|
|
103
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, {
|
|
104
|
+
expression: luau_ast_1.default.globals.exports,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (mustPushExports) {
|
|
109
|
+
luau_ast_1.default.list.unshift(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.VariableDeclaration, {
|
|
110
|
+
left: luau_ast_1.default.globals.exports,
|
|
111
|
+
right: luau_ast_1.default.map(),
|
|
112
|
+
}));
|
|
113
|
+
for (const [exportKey, exportId] of exportPairs) {
|
|
114
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Assignment, {
|
|
115
|
+
left: luau_ast_1.default.property(luau_ast_1.default.globals.exports, exportKey),
|
|
116
|
+
operator: "=",
|
|
117
|
+
right: exportId,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, {
|
|
121
|
+
expression: luau_ast_1.default.globals.exports,
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
else if (exportPairs.length > 0) {
|
|
125
|
+
const fields = luau_ast_1.default.list.make();
|
|
126
|
+
for (const [exportKey, exportId] of exportPairs) {
|
|
127
|
+
luau_ast_1.default.list.push(fields, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.MapField, {
|
|
128
|
+
index: luau_ast_1.default.string(exportKey),
|
|
129
|
+
value: exportId,
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, {
|
|
133
|
+
expression: luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Map, {
|
|
134
|
+
fields,
|
|
135
|
+
}),
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function getLastNonCommentStatement(listNode) {
|
|
140
|
+
while (listNode && luau_ast_1.default.isComment(listNode.value)) {
|
|
141
|
+
listNode = listNode.prev;
|
|
142
|
+
}
|
|
143
|
+
return listNode;
|
|
144
|
+
}
|
|
145
|
+
function transformSourceFile(state, node) {
|
|
146
|
+
const symbol = state.typeChecker.getSymbolAtLocation(node);
|
|
147
|
+
(0, assert_1.assert)(symbol);
|
|
148
|
+
state.setModuleIdBySymbol(symbol, luau_ast_1.default.globals.exports);
|
|
149
|
+
const statements = (0, transformStatementList_1.transformStatementList)(state, node, node.statements, undefined);
|
|
150
|
+
handleExports(state, node, symbol, statements);
|
|
151
|
+
const lastStatement = getLastNonCommentStatement(statements.tail);
|
|
152
|
+
if (!lastStatement || !luau_ast_1.default.isReturnStatement(lastStatement.value)) {
|
|
153
|
+
const outputPath = state.pathTranslator.getOutputPath(node.fileName);
|
|
154
|
+
if (state.rojoResolver.getRbxTypeFromFilePath(outputPath) === rojo_resolver_1.RbxType.ModuleScript) {
|
|
155
|
+
luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, { expression: luau_ast_1.default.nil() }));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const headerStatements = luau_ast_1.default.list.make();
|
|
159
|
+
luau_ast_1.default.list.push(headerStatements, luau_ast_1.default.comment(` Compiled with roblox-ts v${constants_1.COMPILER_VERSION}`));
|
|
160
|
+
if (state.usesRuntimeLib) {
|
|
161
|
+
luau_ast_1.default.list.push(headerStatements, state.createRuntimeLibImport(node));
|
|
162
|
+
}
|
|
163
|
+
const directiveComments = luau_ast_1.default.list.make();
|
|
164
|
+
while (statements.head && luau_ast_1.default.isComment(statements.head.value) && statements.head.value.text.startsWith("!")) {
|
|
165
|
+
luau_ast_1.default.list.push(directiveComments, luau_ast_1.default.list.shift(statements));
|
|
166
|
+
}
|
|
167
|
+
luau_ast_1.default.list.unshiftList(statements, headerStatements);
|
|
168
|
+
luau_ast_1.default.list.unshiftList(statements, directiveComments);
|
|
169
|
+
return statements;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=transformSourceFile.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import luau from "@roblox-ts/luau-ast";
|
|
2
|
+
import { TransformState } from "..";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
export declare function transformStatementList(state: TransformState, parent: ts.Node | undefined, statements: ReadonlyArray<ts.Statement>, exportInfo?: {
|
|
5
|
+
id: luau.AnyIdentifier;
|
|
6
|
+
mapping: Map<ts.Statement, Array<string>>;
|
|
7
|
+
}): luau.List<luau.Statement<luau.SyntaxKind>>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transformStatementList = transformStatementList;
|
|
7
|
+
const luau_ast_1 = __importDefault(require("@roblox-ts/luau-ast"));
|
|
8
|
+
const transformStatement_1 = require("./statements/transformStatement");
|
|
9
|
+
const createHoistDeclaration_1 = require("../util/createHoistDeclaration");
|
|
10
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
11
|
+
function getLastToken(parent, statements) {
|
|
12
|
+
if (statements.length > 0) {
|
|
13
|
+
const lastStatement = statements[statements.length - 1];
|
|
14
|
+
const lastToken = lastStatement.parent.getLastToken();
|
|
15
|
+
if (lastToken && !typescript_1.default.isNodeDescendantOf(lastToken, lastStatement)) {
|
|
16
|
+
return lastToken;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (parent) {
|
|
20
|
+
return parent.getLastToken();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function transformStatementList(state, parent, statements, exportInfo) {
|
|
24
|
+
var _a;
|
|
25
|
+
const result = luau_ast_1.default.list.make();
|
|
26
|
+
for (const statement of statements) {
|
|
27
|
+
const [transformedStatements, prereqStatements] = state.capture(() => (0, transformStatement_1.transformStatement)(state, statement));
|
|
28
|
+
if (state.compilerOptions.removeComments !== true) {
|
|
29
|
+
luau_ast_1.default.list.pushList(result, state.getLeadingComments(statement));
|
|
30
|
+
}
|
|
31
|
+
const hoistDeclaration = (0, createHoistDeclaration_1.createHoistDeclaration)(state, statement);
|
|
32
|
+
if (hoistDeclaration) {
|
|
33
|
+
luau_ast_1.default.list.push(result, hoistDeclaration);
|
|
34
|
+
}
|
|
35
|
+
luau_ast_1.default.list.pushList(result, prereqStatements);
|
|
36
|
+
luau_ast_1.default.list.pushList(result, transformedStatements);
|
|
37
|
+
const lastStatement = (_a = transformedStatements.tail) === null || _a === void 0 ? void 0 : _a.value;
|
|
38
|
+
if (lastStatement && luau_ast_1.default.isFinalStatement(lastStatement)) {
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
if (exportInfo) {
|
|
42
|
+
const containerId = exportInfo.id;
|
|
43
|
+
const exportMapping = exportInfo.mapping.get(statement);
|
|
44
|
+
if (exportMapping !== undefined) {
|
|
45
|
+
for (const exportName of exportMapping) {
|
|
46
|
+
luau_ast_1.default.list.push(result, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.Assignment, {
|
|
47
|
+
left: luau_ast_1.default.property(containerId, exportName),
|
|
48
|
+
operator: "=",
|
|
49
|
+
right: luau_ast_1.default.id(exportName),
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (state.compilerOptions.removeComments !== true) {
|
|
56
|
+
const lastToken = getLastToken(parent, statements);
|
|
57
|
+
if (lastToken) {
|
|
58
|
+
luau_ast_1.default.list.pushList(result, state.getLeadingComments(lastToken));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=transformStatementList.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import luau from "@roblox-ts/luau-ast";
|
|
2
|
+
import { TransformState } from "..";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
export declare function transformWritableExpression(state: TransformState, node: ts.Expression, readAfterWrite: boolean): luau.WritableExpression;
|
|
5
|
+
export declare function transformWritableAssignment(state: TransformState, writeNode: ts.Expression, valueNode: ts.Expression, readAfterWrite?: boolean, readBeforeWrite?: boolean): {
|
|
6
|
+
writable: luau.WritableExpression;
|
|
7
|
+
readable: luau.WritableExpression;
|
|
8
|
+
value: luau.Expression<luau.SyntaxKind>;
|
|
9
|
+
};
|