159
questions
0
votes
0
answers
28
views
How to export a function in a namespace
I have the following file directory:
├── UseCases
| ├── SistemParamsUseCases
| | ├── getAll. ts
| | ├── getParam. ts
| | ├── SistemParamsUseCases. ts
Inside getAll.ts and getParam.ts I ...
0
votes
0
answers
49
views
How to preserve auto-completion and avoid namespace in TypeScript Files which exports functions
I'm currently working on a project where I have a lot of files like that, exporting functions like this:
// file: myFunctions.ts
// Function 1
export function add(a: number, b: number): number {
...
0
votes
0
answers
116
views
Javascript with namespace in R Shiny
Does any one know how to put Javascript with namespace in R Shiny?
I create a Shiny module to add draggable text to Sankey plot, right click at the text will give an option to remove it from the plot. ...
1
vote
0
answers
61
views
Namespace RequireJS in JS API to avoid conflicts with 3rd party AMD libraries
I want to include jquery and jquery UI along with requirejs( at top of the header ).
with WordPress starting to utillize dynamic module loading and React, primarily in its administrative dashboard and ...
1
vote
1
answer
183
views
Calling google.script.run with Namespace Functions
I've been migrating an old javascript project to GAS and am hitting a blocker on trying to run namespace functions from the client-side web app. Quick code example:
var foo = function() {
function ...
1
vote
0
answers
32
views
Using namespaced functions in jQuery.fn
This seems like it should be obvious, but I can not figure out how to properly use namespaced (dotted) function names in jQuery.fn.
More precisely, using this in a function embedded in an object ...
1
vote
0
answers
3k
views
Cannot find namespace - ts(2503) [Exporting a namespace]
I am trying to export mongoose.Types in two different ways so that I can access it in another file to create interfaces or types. Why does 1 approach work and the other one doesn't? E.g
❌ This doesn't ...
0
votes
0
answers
552
views
Insert new interface method namespace Typescript
I am working with a third-party library that has a namespace thisLibrary and within that namespace has an interface Options. I would like to add a property to the Options interface and then use the ...
3
votes
2
answers
339
views
How to best emulate namespaces in Typescript?
I realize that namespaces are essentially deprecated in ES6 and don't work well in Visual Code.
But I still want to use them. Why? Because I have code spread across multiple files that I want to group ...
0
votes
1
answer
85
views
double namespaced routing issues with fetch
Hello> Im creating a Javascript SPA/Rails Api that has books and users. I using namespace in my routes,along with serializers for each model. Im not sure why im getting this error when trying to do ...
0
votes
1
answer
2k
views
export namespace in namespace
Can I export a namespace A with another namespace B in it? Something like:
// b.ts
export namespace B {
export const val = 'val';
}
// a.ts
export namespace A {
//... some thing import b as ...
0
votes
0
answers
139
views
Added click event to span tag and its getting called twice from namespace
I do have a span tag that I added a click event to and it gets called twice even though I only click it once and I have no idea why. If I run this code in a separate project then the button only gets ...
0
votes
2
answers
72
views
Accessing a JavaScript variable from a namespace at a "global" level on the same page
I'm trying to access a variable from a namespace on the same page at a "global" level but thus far have been unable to do so. Here's the code:
window.addEventListener('resize',
() => ...
-1
votes
1
answer
315
views
Nested functions error, Unexpected token ':', Cannot read property of undefined
I want to make my code more clear, that the reason i am trying to learn namespaces or nested functions. I've read about them in several places and as i understood 'Revealing Module' is the best option....
0
votes
0
answers
202
views
How would I export imported namespaces which were generated in typescript?
My project is a microservices project which generates some typescript from .proto files (not relevant). I'd like to create a local npm package that exports what's in these files, in addition to some ...
42
votes
6
answers
50k
views
How to turn on the 'throwIfNamespace' flag in React.js
I have some code like below in my component.
<svg id="SvgjsSvg3254" width="318" height="152" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:...
2
votes
1
answer
995
views
Trouble instantiating p5.js code (instance mode)
Update: Question has been solved. Here's the working instantiated code in case anybody needs it for help/reference: https://editor.p5js.org/Rod1C/sketches/iaKn9CKCS
I'm new to p5.js and have been ...
2
votes
0
answers
257
views
Understanding this in module/namespace and arrow functions
After some research on how to write modular/namespace in javascript, I saw that the following might be a good idea on how to encapsulate a function/object:
var MODULE = (function (parent) {
...
0
votes
1
answer
305
views
How to import or use functions defined in third party namespace in javascript?
This could be the very basic question of javascript but i am not able to figure out to use the namespance named AudioBridge from the kandy.js file but i dont how should i import the audioBridge ...
0
votes
2
answers
843
views
Javascript : Eval external script within defined namespace
Sorry for the essay, couldn't find a short way to explain this :(
Context
I am currently building a WebPart for Office 365 which is pretty much like a client side App that users can add to their ...
-1
votes
1
answer
50
views
Is it possible to arrange Java Script files in to 'name spaces' to avoid conflicts?
I'm building a website using a premium html template, part of the template is in Javascript. So in the template I have something like this - its in the 'master template' every page.
//Template JS
<...
0
votes
2
answers
4k
views
General TypeScript usage for modules / namespaces
I have a standard web page (not an app rendered with angular, react, vue, etc) that uses jQuery, and other libraries.
I want to integrate good practices with TypeScript.
What is the best way to do ...
0
votes
1
answer
94
views
JavaScript window namespacing - could I get some insight into what this is doing please?
I have some code that I am struggling to understand. I'm no expert in JavaScript (I have a basic grasp), and I've been reading about the DOM and namespacing (and console.log()'ing the variables) to ...
0
votes
1
answer
405
views
Bundle javascript library with namespace and classes in different files
I have different files with namespace and classes like this:
1) namespace.js:
var somenamespace = window.somenamespace || {};
2) class1.js:
somenamespace.class1= (function() {
var _public = {};
...
0
votes
1
answer
33
views
Understanding of namespace in JavaScript [duplicate]
I'm fairly new to JavaScript though I do have some programming experience with Python.
My problem is, that I do not seem understand the concept of namespace in JS since it appears to be different than ...
3
votes
1
answer
2k
views
TypeScript: Substitute Namespaces with something else
TSLint complains that namespaces shouldn't be used and as far as I understand the common sense is that they shouldn't be used anymore as they are special TypeScript construct.
So, I have a simple ...
0
votes
2
answers
585
views
How to access a function or variable in a script run with $.getScript
Is there some way to access the namespace of a script after it is run with $.getScript? Since plugin is defined in the global scope, I would have thought I'd be able to run it.
index.js
$.getScript('...
1
vote
0
answers
42
views
ES6 Import Named Exports In Namespace [duplicate]
In ES6, I know that you can import named exports like:
import { foo } from 'bar'
Which is useful in certain module bundlers like Webpack
so that it is aware of exactly what is being used in any ...
0
votes
0
answers
203
views
how to access a namespace variable directly in the event bind function
I'm rewriting my JS code to make it more clear and precise. I define one module in namespace and not able to pass the same variable in that bind function, see below code:
// Gmap Autocomplete ...
1
vote
0
answers
196
views
WebStorm refactor JavaScript variable namespace
I have polluted one of my classes with too many functions. Now, I want to clean it up by introducing several namespaces.
Consider following example:
const Tool = {};
tool.fct1 = function() { /* ... ...
-1
votes
1
answer
452
views
ajax is not a function inside a namespace
I am trying to create a namespace that contains all the calls of my application, but I do not know why when I try to do an Ajax call inside the namespace it says that ajax is not a function
I Tried ...
1
vote
1
answer
67
views
Package imported into Node.js TypeScript file not recognized by namespace section declaration?
I am using JetBrain's WebStorm IDE to edit a TypeScript file as part of a Node.js v8.6.0 project. I have the JavaScript version for the project set to JSX Harmony. At the top of the TypeScript ...
0
votes
2
answers
730
views
Select element with specific tag name but with any namespace by using javascript querySelector
How can i use document.querySelector or document.querySelectorAll to get specific tag with any namespace.
I cannot use JQuery or any other library.
Ex
<mml:math>
<mml:row>
</...
1
vote
3
answers
593
views
JavaScript namespace object literal
I've recently come across JavaScript Namespaces and how you can use them to create namespaces like other popular OOP languages. I have confusion on how they are declared. For example,
var myNamespace ...
0
votes
2
answers
2k
views
How to write a middleware for the functions in typescript namespace
I want to write a middleware for the namespace in typescript. So when any function in the namespace is called, middleware should trigger and check if the intended function can be executed. Example:
...
0
votes
1
answer
949
views
javascript access function from another namespace in namespaced ajax functions callback
I need some help with my javascript code. I just recently started using namespaces and I have a problem which I am not able to solve.
I have two files data.js and themes.js with a namespace on each ...
1
vote
0
answers
188
views
how to use namespace in typescript
File1.ts
namespace ServiceUrls {
export class ServiceUrls {
static baseUrl: string = 'http://localhost:52949/V1/';
static baseImageUrl: string = 'http://localhost:52949/';
...
0
votes
1
answer
208
views
Why does "use strict" break function assignment inside namespace to global scope?
I have library code does a simple function assignment. This function is accessed from the global scope.
When I add "use strict" at the beginning of the file, I get an error TypeError: a is undefined, ...
0
votes
1
answer
93
views
Detecting a Non-Namespaced Event in jQuery
I'm trying to detect with jQuery's on only events that are not namespaced.
I tried checking the namespace within the callback of on as follows, but it's always undefined:
$(".selector").on(
"...
-1
votes
1
answer
82
views
How to have nested object inside namespace variable?
I am programming using namespaces, and so far I have only used variables and functions inside it. I tried to do a nested object in it, but it doesn't seem to work like I expect it. Here's the code
...
0
votes
1
answer
3k
views
browser returns an error: app is not defined
I have an app running on Backbone in front-end and when a browser loads a page it returns an error in the console:
Uncaught ReferenceError: app is not defined
at index.js:6
at index.js:51
(...
2
votes
2
answers
4k
views
How to correctly import the same namespace in two different files in Typescript
I'm having an issue in understanding how to make two files with the same namespace and import one into the other in Typescript.
This is the situation:
file1.ts
export namespace nspace {
export ...
0
votes
1
answer
18
views
for namespaced js modules are non-namespaced file names normally used?
For namespaced js modules are non-namespaced file names normally used? C# class filenames, for example, usually reflect only the basic class name as opposed to the fully namespaced class name. So, ...
0
votes
1
answer
64
views
Different JS Namespace declarations
I wonder, are the following code example the same?
Version 1:
var myNamespace = {};
myNamespace.say = function() {...}
Version 2 (JS-Fiddle: https://jsfiddle.net/542wbkat/) :
var myNamespace = new ...
-1
votes
2
answers
46
views
Why won't a function within a "namespace" JavaScript file populate a dropdownlist?
I have 2 external JavaScript files, one is set up like a "namespace", and the other file calls it.
Here is how my "namespace" looks like
var GlobalScript = {
GetAllStates: function () {
$...
0
votes
0
answers
275
views
Want to reuse the functions return value, Function is in namespace Jquery
I have a very basic and simple question.
I am using the pattern as below for declaring namespace:
$.Test= {
CheckIfListExist: function () {
//Something is happening here
},
...
0
votes
2
answers
350
views
Is there a way around to create TypeScript classes in closures?
I'm using IntelliJ IDEA's File Watcher to automatically compile the TypeScript files, but for some reason it's not liking classes defined within blocks / function closures:
Is there a way around this ...
2
votes
2
answers
819
views
Namespace issue in google closure library
In the tutorial mentioned here, the namespace provided by the module is:
goog.provide('tutorial.notepad.Note');
But I am wondering why not this:
goog.provide('tutorial.notepad');
Since, according ...
0
votes
1
answer
374
views
How does IIFE protect namespacing?
I'm reading an article about IIFEs but feel that the main value it brings is that it creates privacies for variables in the sense that in the below code, "i" can't be changed if placed in an IIFE. But ...
0
votes
1
answer
281
views
Create object of namespace Javascript singleton class
I am new to IIFE and trying to implement namespace in JavaScript on a Siungleton JavaScript class:
I have a JavaScript class (say main class):
var myIIFE = (function () {
var x = null;
//...