From d4c1ea4bba2f0faca3d64590fd267cf978408f4b Mon Sep 17 00:00:00 2001 From: spaceface777 Date: Wed, 20 May 2020 20:34:37 +0200 Subject: [PATCH] jsgen: fix jsdoc class namespacing bug --- vlib/v/gen/js/js.v | 4 ++-- vlib/v/gen/js/tests/js.js | 4 ++-- vlib/v/gen/js/tests/simple.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vlib/v/gen/js/js.v b/vlib/v/gen/js/js.v index f8261459c5..bf2050be99 100644 --- a/vlib/v/gen/js/js.v +++ b/vlib/v/gen/js/js.v @@ -212,8 +212,8 @@ pub fn (mut g JsGen) typ(t table.Type) string { return res + ') => ' + g.typ(info.func.return_type) } // Struct instance => ns["class"]["prototype"] - if sym.kind == .struct_ { - return g.to_js_typ(styp) + '["prototype"]' + if sym.kind == .struct_ && get_ns(styp).len > 0 { + return g.to_js_typ(g.get_alias(styp)) + '["prototype"]' } return g.to_js_typ(styp) } diff --git a/vlib/v/gen/js/tests/js.js b/vlib/v/gen/js/tests/js.js index 86a9cacc2d..ea4e320cc4 100644 --- a/vlib/v/gen/js/tests/js.js +++ b/vlib/v/gen/js/tests/js.js @@ -1,5 +1,5 @@ // V_COMMIT_HASH 74686d0 -// V_CURRENT_COMMIT_HASH 577d252 +// V_CURRENT_COMMIT_HASH 0d3f133 // Generated by the V compiler "use strict"; @@ -74,7 +74,7 @@ const hello = (function () { const main = (function (hl) { class Foo { /** - * @param {{a?: hello["A"]["prototype"]}} values - values for this class fields + * @param {{a?: hl["A"]["prototype"]}} values - values for this class fields * @constructor */ constructor(values) { diff --git a/vlib/v/gen/js/tests/simple.js b/vlib/v/gen/js/tests/simple.js index b82664cd6f..a7d189af19 100644 --- a/vlib/v/gen/js/tests/simple.js +++ b/vlib/v/gen/js/tests/simple.js @@ -1,5 +1,5 @@ // V_COMMIT_HASH 74686d0 -// V_CURRENT_COMMIT_HASH 577d252 +// V_CURRENT_COMMIT_HASH 0d3f133 // Generated by the V compiler "use strict";