From ba66c91729f4794ed0348cd8c37422a734933ecb Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 23 Dec 2018 22:56:04 +0100 Subject: [PATCH] Fixed building process --- shared/js/bookmarks.ts | 8 ++++---- shared/js/main.ts | 6 +++--- tools/dtsgen/declarator.ts | 21 ++++++++++++++++++++- tools/dtsgen/test/test_03.ts | 9 +++++++++ vendor/bbcode | 2 +- 5 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 tools/dtsgen/test/test_03.ts diff --git a/shared/js/bookmarks.ts b/shared/js/bookmarks.ts index 64851490..34257327 100644 --- a/shared/js/bookmarks.ts +++ b/shared/js/bookmarks.ts @@ -29,7 +29,7 @@ namespace bookmarks { } export interface Bookmark { - type: BookmarkType.ENTRY; + type: /* BookmarkType.ENTRY */ BookmarkType; /* readonly directory: DirectoryBookmark; */ server_properties: ServerProperties; @@ -44,7 +44,7 @@ namespace bookmarks { } export interface DirectoryBookmark { - type: BookmarkType.DIRECTORY; + type: /* BookmarkType.DIRECTORY */ BookmarkType; readonly content: (Bookmark | DirectoryBookmark)[]; unique_id: string; @@ -93,7 +93,7 @@ namespace bookmarks { if(entry.unique_id == uuid) return entry; if(entry.type == BookmarkType.DIRECTORY) { - const result = find_bookmark_recursive(entry, uuid); + const result = find_bookmark_recursive(entry as DirectoryBookmark, uuid); if(result) return result; } } @@ -147,7 +147,7 @@ namespace bookmarks { else for(const entry of parent.content) if(entry.type == BookmarkType.DIRECTORY) - delete_bookmark_recursive(entry, bookmark) + delete_bookmark_recursive(entry as DirectoryBookmark, bookmark) } export function delete_bookmark(bookmark: Bookmark | DirectoryBookmark) { diff --git a/shared/js/main.ts b/shared/js/main.ts index 719ad559..e7acb5c0 100644 --- a/shared/js/main.ts +++ b/shared/js/main.ts @@ -21,9 +21,9 @@ const js_render = window.jsrender || $; const native_client = window.require !== undefined; function getUserMediaFunction() { - if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) - return (settings, success, fail) => { navigator.mediaDevices.getUserMedia(settings).then(success).catch(fail); }; - return navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; + if((navigator as any).mediaDevices && (navigator as any).mediaDevices.getUserMedia) + return (settings, success, fail) => { (navigator as any).mediaDevices.getUserMedia(settings).then(success).catch(fail); }; + return (navigator as any).getUserMedia || (navigator as any).webkitGetUserMedia || (navigator as any).mozGetUserMedia; } function setup_close() { diff --git a/tools/dtsgen/declarator.ts b/tools/dtsgen/declarator.ts index 9f381814..6b05dfc4 100644 --- a/tools/dtsgen/declarator.ts +++ b/tools/dtsgen/declarator.ts @@ -321,11 +321,30 @@ generators[SyntaxKind.ClassDeclaration] = (settings, stack, node: ts.ClassDeclar return ts.createClassDeclaration(node.decorators, append_export(append_declare(node.modifiers, !stack.flag_declare), stack.flag_namespace), node.name, node.typeParameters, node.heritageClauses, members as any); }; +generators[SyntaxKind.PropertySignature] = (settings, stack, node: ts.PropertySignature) => { + console.log(SyntaxKind[node.type.kind]); + let type: ts.TypeNode = node.type; + switch (node.type.kind) { + case SyntaxKind.LiteralType: + type = ts.createIdentifier("any") as any; + } + + return ts.createPropertySignature(node.modifiers, node.name, node.questionToken, type, undefined); +}; + generators[SyntaxKind.InterfaceDeclaration] = (settings, stack, node: ts.InterfaceDeclaration) => { if(settings.remove_private.field && has_private(node.modifiers)) return; if(stack.flag_namespace && !has_modifier(node.modifiers, SyntaxKind.ExportKeyword)) return; - return node; + const members: any[] = []; + for(const member of node.members) { + if(generators[member.kind]) + members.push(generators[member.kind](settings, stack, member)); + else + members.push(member); + } + + return ts.createInterfaceDeclaration(undefined, append_export(append_declare(node.modifiers, !stack.flag_declare), stack.flag_namespace), node.name, node.typeParameters, node.heritageClauses, members); }; generators[SyntaxKind.VariableDeclaration] = (settings, stack, node: ts.VariableDeclaration) => { diff --git a/tools/dtsgen/test/test_03.ts b/tools/dtsgen/test/test_03.ts new file mode 100644 index 00000000..d41ecbfd --- /dev/null +++ b/tools/dtsgen/test/test_03.ts @@ -0,0 +1,9 @@ +enum YY { + H = "C", + B = "Y" +} + +interface X { + type: "", + c: YY.B +} \ No newline at end of file diff --git a/vendor/bbcode b/vendor/bbcode index 032446b4..a48cdd85 160000 --- a/vendor/bbcode +++ b/vendor/bbcode @@ -1 +1 @@ -Subproject commit 032446b477a5fec8cccc6c3632a0bcbf521b9c0f +Subproject commit a48cdd857059ff7640c93fa4f0e226739943e4d9