When attempting to compile the import statement directly, it functions improperly; however, upon saving it in VS Code, it works

I have encountered an issue where a specific import fails to work during direct compilation, but functions properly after saving the source on VS Code.

If I delete the node_modules/.cache folder and run the command:

yarn serve

It compiles without errors, however, the browser shows a runtime error:

Uncaught TypeError: getParamNames is not a function
    at eval (webpack-internal:///../api/src/clients/base.ts:116)
    [more error details...]

If I continue compiling the application without any changes, the error persists. However, if I edit base.ts in VS Code, change the import to something incorrect, then revert it back, it compiles successfully. Even after restarting the server, the error does not reappear.

If I delete the node_modules/.cache again or wait for it to expire, the cycle repeats.

base.ts:

[content of base.ts]

package.json:

[content of package.json]

tsconfig.json:

[content of tsconfig.json]

vue.config.js:

[content of vue.config.js]

babel.config.js:

[content of babel.config.js]

Addendum (2020-03-20)

I was able to partially resolve this by creating an explicit type declaration and adjusting the import statement. This solution worked for the frontend built with vue-cli, but not for the backend built with ts-node-dev.

[error message from ts-node-dev]

This issue seems similar to:

Answer №1

Resolved all issues by enabling "esModuleInterop": true in the tsconfig.json file and updating the import statements to use

getParamNames from 'get-param-names'
.

As a result, both vue-cli and es-node-dev now compile the code consistently. Additionally, Jest required some additional type information in its unit tests, but was functioning properly afterwards.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What sets apart two pieces of TypeScript code from each other?

When I first started learning TypeScript, I encountered an issue that has me stuck. In my code, there are two versions: in the first version, there is an object called name, and in the second version (which is essentially the same), the variable name has ...

What is the best way to transform a TypeScript interface into JSON format?

Is there a way to convert the contents of d.ts files into JSON format? I'm looking to extract the structure of functions in d.ts files and display them as JSON or an abstract syntax tree. Can anyone guide me on how to go about this process? Essentiall ...

Is there a way to execute Typescript tests using JasmineKarma within a TFS Build Process?

My current setup involves a web application using Angular 1.5 with bower/npm/gulp written in Typescript for our build process. The back end is a c# .net WebApi2, and both are built and deployed on TFS2015. Integrating my c# NUnit tests into the build proce ...

Showing various checkbox values using Angular 2 in a mixture of HTML and TypeScript

I am facing an issue where I need to select multiple checkboxes and then, upon clicking the Testing button, display all the selected boxes in the console. Currently, I have only implemented a single checkbox that is displayed in multiple rows. My setup inv ...

How can we activate intellisense for a Vue component's template HTML?

Although I am still fairly new to Vue, I have a strong background in Typescript and Angular. Currently, I am embracing Typescript and utilizing the vue-class-component and vue-property-decorator libraries following the recommendations in the Vue documentat ...

The Fusion of Apollo GraphQL Server and TypeScript: A Match Made

Lately, I've been immersed in a project that utilizes the node.js + express + typescript + Apollo server stack. During my research on Apollo client, I came across the TypeScript section, but surprisingly found little information regarding TypeScript f ...

Ways to resolve the issue of npm being unable to globally install typescript

While trying to globally install TypeScript using npm sudo npm install -g typescript An error occurs during the installation process with the following message: ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/typescript/bin/ ...

A Nuxt plugin that integrates a separate website into the serverMiddleware

The concept Imagine having a main Nuxt website just like any other. Now, think about adding my module to your project. This module will then introduce a subdomain "admin.example.com" to your project, creating a fully functional Nuxt-based website that ope ...

What is preventing this generic key conditional from being immediately resolved?

function broken<T>(value: T) { type Test = keyof T extends keyof T ? 1 : 0 } Is there a reason why Test in the given example cannot be immediately resolved as 1? I'm seeking clarification from the compiler to help me understand this. Interes ...

Using Vue and PHP to parse a JSON string and display it as a table

I am currently facing a challenge in parsing a JSON string from my Laravel application to my Vue view. The format of the JSON string could be as follows: { "1":[ { "row":"Some text here on first column." }, { "row":"And more text. Second row ...

What steps do I take to eliminate this additional content?

Currently working on a web messenger project and facing an issue with a specific bar that I want to remove from my interface: https://i.sstatic.net/sp05i.png Within the Home.blade.php file, the code snippet looks like this: @extends('layouts.texter& ...

How can you selectively conceal the nth item in a v-for loop while keeping the original array intact? Discover a way to do this using the search function

I have a reference variable called foxArticles that holds a list containing 100 items. Using a v-for loop, I iterate over each value and render all 100 values on the page. <template> <div class="news_container"> <div v- ...

Adjust the route display according to the name of the route

I am currently using google maps in a div, and I want to switch the view to another one when changing routes. I attempted to achieve this with the code below, but it did not work as expected. .map-col(ref="mapCol" v-if="route.name == ' ...

Angular Material's <mat-select> tag allows for the inclusion of an <input> element within it

I am attempting to place an input element inside the mat-select tag of the Angular Material element. However, I am facing an issue where I cannot input any text into the input field inside the select element. Below is the code I am using to search for elem ...

How can I iterate through a variable in TypeScript?

initialize() { var elements = []; for (let i = 1; i <= 4; i++) { let node = { name: `Node ${i}` }; elements.push({ [`node${i}`]: node }); if (i < 4) { let edge = { source: `node${i}`, target: ...

The function passed as a prop is unrecognized

I am having an issue with passing the function toggle and it is showing as undefined. Any advice on how to resolve this? function page() { const [open, setOpen] = React.useState(false); const handleToggle = () => { setOpen(!open); }; ...

Tips for efficiently transmitting JSON information from Nuxt Axios to a FastAPI server via a POST operation

Currently, I am attempting to transmit user data from Nuxt.js using Axios through a POST request. The data is being fetched via a JavaScript CDN function that returns an object containing user parameters, so avoiding the usage of a form is preferred as I w ...

Retrieve various data types through a function's optional parameter using TypeScript

Creating a custom usePromise function I have a requirement to create my own usePromise implementation. // if with filterKey(e.g `K=list`), fileNodes's type should be `FileNode` (i.e. T[K]) const [fileNodes, isOk] = usePromise( () => { ...

How can I utilize Axios in Vue.js to access a local JSON file?

I'm trying to figure out how to read a local JSON file using Axios. The data.json file is located in public/info/data.json. However, every time I attempt to make a get request, I receive a 404 error message. Here is the content of data.json: [ {" ...

Vue combined with Grapejs

Currently, I am utilizing Grapejs with Vue and everything appears to be functioning properly. However, I am encountering an issue with the "grapesjs-preset-webpage" library. I am struggling to incorporate additional HTML options, such as "Columns", "Video ...