What's the best way to ensure you're linting the correct file type for importing in Web

Upon installation of WebStorm, I encountered an issue when opening an existing Vue/TypeScript project. The IDE was not correctly importing and linting some file imports that were functioning properly through ESLint/webpack.

In my usage of Vue 2.x with composition API and single-file components, I typically import files under

<script lang="ts">
with explicit file extensions except for .ts files, which do not require the extension to be specified.

This particular project presented a recurring scenario where both a .vue and a .ts file shared the same name within the same folder - for example: App.vue and App.ts.

While working in App.vue, I attempted to import App.ts as follows:

<script lang="ts">
import { someFunction } from './App';

// export defineComponent({
//  ...

The IDE highlighted the exported member in red with a tooltip indicating "Element not exported". The file path couldn't be resolved, preventing me from using functionalities like Command + Click or viewing types of exported members.

Addition of the .ts extension resolved this issue, but then ESLint/webpack started throwing errors. Despite this problem, the project continued to function correctly, highlighting an unresolved path resolution specifically within WebStorm.

I experimented with various settings in "Code Style | TypeScript" and spent several hours searching online for solutions, yet the issue persisted.

Although my initial experience with WebStorm has been positive, I'm currently unable to surmount this obstacle.

Your assistance would be greatly appreciated

Answer №1

Currently, there is a known issue that you can track for updates at WEB-53277.

At this time, the only solution is to use distinct names for files with the extensions .ts and .vue within the same folder.

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

"Notification: The marker element has been eliminated" encountered while attempting to restore text ranges using Rangy within a Vue component

I have a rather intricate Vue component that includes a contenteditable div. My goal is to highlight words within this div using the Rangy library and add extra markup while retaining this markup even after editing the text. Initially, I planned on asking ...

The cart total variable in Vuejs is coming back as NaN

I'm currently in the process of creating a cart system using vuejs and I've encountered an issue where my total variable is displaying NaN instead of calculating the total price of all products. Below is the function responsible for calculating ...

Read PDF on Nuxt site

I am working on a Nuxt app and I need to display a PDF file containing the GDPR policy on a specific page, such as /gdpr. I attempted to place the PDF in the static folder, but accessing it through a URL like /gdpr.pdf did not work. I have been unable to ...

Can you please provide a step-by-step guide for using socket.io with TypeScript and webpack, after installing it

Currently, I am experimenting with TypeScript in conjunction with node.js, socket.io, and webpack. To facilitate this setup, I have configured the webpack.config.js, tsconfig.json, and tsd.json files. Additionally, I acquired the typings file for socket.i ...

Handling HTTP calls in Vue.js before the beforeunload event

I am facing an issue with the beforeunload event in my Vue.js application. I have a scenario where I need to make an HTTP call to check if the user is still logged in or if their session has expired on the backend. However, it seems that the event does no ...

Assign a value to a file input in Angular 6

I'm currently working with Angular 6 and I have a requirement to retrieve an image that is dropped into a div element and assign it as the value of an input type="file" within a form. The process involves the user dropping an image into the designate ...

invoking a function within an object in Typescript

export class MockedDataService { constructor(private Session: SessionService) {} private getMockedResponse(name:string){ return ""; // placeholder for the response data, will be a promise } public mocked:{ products:{ ...

Definition for the type react-navigation-v6 <Stack.Group>

I'm having trouble figuring out the proper type definition for a Stack group that includes screens (refer to TestStack.Group and the nested TestStack.Screen). The navigation stack: const TestStack = createNativeStackNavigator<TestStackParamList> ...

Is there a way to send map data using props in React?

I just want to store and pass the current props.url to the videomodal so I can show the same active video on the video modal. I can't use useState in the map. How can I pass it? Or is there any other solution? Videos.tsx ( props.url must be in the &l ...

What could be causing the removal of inline styles in my Vue.js application?

I have integrated a calendar component from Tailwind UI into my Vue.js application. However, I am facing an issue with the following line of code: <div class="col-start-1 col-end-2 row-start-1 grid divide-y divide-gray-100" style="grid-t ...

Vue - relocating child component code to a separate file

Within my current setup using Vue and PHP without access to ES6, I have a subcomponent within a file that I need to extract into another file. Since I am not using the CLI and cannot use import statements, how can I properly organize my code? const form ...

Eliminate the need for require statements in TypeScript-generated JavaScript files

I am working on a website project and utilizing TypeScript for development. While using the tsc compiler, I noticed that all my JavaScript code compiles correctly. However, when I include an import statement in my TypeScript files, it gets compiled into J ...

What are the steps to transpile NextJS to es5?

Is it possible to create a nextjs app using es5? I specifically require the exported static javascript to be in es5 to accommodate a device that only supports that version. I attempted using a babel polyfill, but after running es-check on the _app file, ...

Publishing Typescript to NPM without including any JavaScript files

I want to publish my *.ts file on NPM, but it only contains type and interface definitions. There are no exported JavaScript functions or objects. Should I delete the "main": "index.js" entry in package.json and replace it with "main": "dist/types.ts" inst ...

Tips for efficiently parsing multiple JSON files in Typescript while maintaining clean and concise code

Currently, my app is designed to read multiple Json files in Typescript and populate select boxes. However, I am striving to avoid repeating code with the wet (write everything twice) principle and keep things dry (don't repeat yourself). Initially, I ...

Check the newest release of the Vue WebApp - Loading the most recent

Currently, I am working on a Vue.js project with the Vuexy BootstrapVue template and deploying it in a Docker container. One issue we are facing is that whenever we push updates to our web application, users need to perform a hard refresh on their browser ...

Utilizing the subclass type as a parameter in inheritance

Looking for a way to restrict a function in C# to only accept classes of a specific base class type? In my current implementation, I have a base class (which can also be an interface) and n-classes that extend it. Here is what I am currently doing: abstr ...

Divide a string using multiple delimiters just one time

Having trouble splitting a string with various delimiters just once? It can be tricky! For instance: test/date-2020-02-10Xinfo My goal is to create an array like this: [test,Date,2020-02-10,info] I've experimented with different approaches, such ...

What is the best way to import and export modules in Node.js when the module names and directories are given as strings?

Here is the structure of my folder: modules module-and index.js module-not index.js module-or index.js module-xor index.js moduleBundler.js The file I'm currently working on, moduleBundler.js, is re ...

Can you explain the distinction between employing 'from' and 'of' in switchMap?

Here is my TypeScript code utilizing RxJS: function getParam(val:any):Observable<any> { return from(val).pipe(delay(1000)) } of(1,2,3,4).pipe( switchMap(val => getParam(val)) ).subscribe(val => console.log(val)); ...