Error message: Duplicate identifier found in Typescript

Encountering an error while trying to run my angular-meteor client (ionic serve), specifically:

[00:29:20]  typescript: node_modules/meteor-typings/1.3/main.d.ts, line: 657 
            Duplicate identifier 'Status'. 

     L657:    type Status = 'connected' | 'connecting' | 'failed' | 'waiting' | 'offline';

[00:29:20]  typescript: node_modules/meteor-typings/1.3/main.d.ts, line: 695 
            Duplicate identifier 'Status'. 

     L695:      type Status = 'connected' | 'connecting' | 'failed' | 'waiting' | 'offline';

[00:29:20]  transpile failed 

The error message within the source code file reads:

TS2300:Duplicate identifier 'Status'
.

This project was constructed following the steps outlined in this tutorial: Most of the files used can be found here: https://github.com/Urigo/Ionic2CLI-Meteor-WhatsApp

Ionic Framework: 2.1.0
Ionic Native: 2.4.1
Ionic App Scripts: 1.1.3
Angular Core: 2.2.1
Angular Compiler CLI: 2.2.1
Node: 6.3.1
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

You can review all relevant files in the codebase here.

Seeking advice on what might be causing this issue and where to investigate further. Despite reverting to previous code versions and reinstalling project requirements by removing node_modules, the same error persists without any obvious changes.

Appreciative of any suggestions or insights that could be offered.

Answer №1

My tsconfig file originally included the following:

"types": [
  "meteor-typings",
  "@types/underscore"
]

After removing 'meteor-typings', everything started functioning properly!

"types": [
  "@types/underscore"
]

In the package.json file, I had the following dependencies listed:

  "devDependencies": {
    "@ionic/app-scripts": "1.1.3",
    "@types/meteor": "^1.3.32",
    "@types/underscore": "^1.7.36",
    "meteor-typings": "^1.3.1",
    "tmp": "0.0.31",
    "typescript": "2.0.9",
    "typescript-extends": "^1.0.1"
  },

I believe that 'meteor-typings' was already being transpiled, causing duplication when specified in the tsconfig file. (This is just my speculation as to why) :)

Answer №2

Just wanted to share that I encountered this issue after upgrading Ionic from version 2.0.0 to 2.2.0.

The solution that worked for me was removing "meteor-typings" from the tsconfig.json file following the tutorial:

"types": [
  "@types/underscore",
  "@types/meteor-accounts-phone",
  "@types/meteor-collection-hooks"
]

Strangely enough, removing just that one type fixed the problem. It's a bit strange but it did the trick for me.

This potentially indicates that the tutorial may need an update, especially for those who are using the latest version of Ionic. I plan on raising this as an issue in their github repository soon.

Answer №3

To clarify further: In the api/tsconfig.json file, make sure to keep the "meteor-typings" in types[] as it is. However, in the root folder, remove any extra "meteor-typings" from types[], and then the program should run smoothly without any errors. Also, don't forget to create a softlink to node_modules inside the api folder.

For Windows users, you can do this by using the following command:

mklink /d \node_modules ..\node_modules

It's important to note that there should not be a package.json file inside the api folder, as explained in the tutorial.

Thank you for providing the solution!

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

How can I make TypeScript properly export function names for closure-compiler?

Here is the TypeScript code I am working with: namespace CompanyName.HtmlTools.Cookie { export function eraseCookie(name:string, path:string) { createCookie(name, "", path, -1); } export function readCookie(name:string) { ...

Typescript Routing Issue - This call does not match any overloads

Need assistance with redirecting to a sign-up page upon button click. Currently encountering a 'no overload matches this call' error in TypeScript. Have tried researching the issue online, but it's quite broad, and being new to Typescript ma ...

How does TypeScript provide me with insights even before compiling with tsc?

As I follow the instructions for incorporating TypeScript into my existing React Native project here, the final step instructs me to: Run yarn tsc to type-check your new TypeScript files. However, when I check VSCode, I am already receiving feedback from ...

The Vue route parameters are not recognized within the function type

Seeking assistance on extracting parameters from my route in a vue page, I have the following implementation: <script lang="ts"> import { defineComponent } from 'vue'; import { useRoute } from 'vue-router'; export ...

Encountering the error "No overload matches this call" while utilizing useQuery in TypeScript may indicate a mismatch in function parameters

My issue lies with TypeScript and types. Here is the API I am working with: export const clientAPI ={ //... getOptions: async (myParam: number) => get<{ options: Options[]; courses: any[] }>(`/courses?myParam=${myParam}`)().then((result) =& ...

developing TypeScript classes in individual files and integrating them into Angular 2 components

We are currently putting together a new App using Angular2 and typescript. Is there a more organized method for defining all the classes and interfaces in separate files and then referencing them within angular2 components? import {Component, OnInit, Pi ...

What is the process for interpreting the status code retrieved from an HTTP Post request?

When sending a POST request to a backend and attempting to read the status code, I encountered the following result: status-code:0 Below are my functions: Service: signIn(uname:string, pass:string): Observable<any> { let headers = new Headers( ...

Leverage Sinon's fakeServer in combination with promises and mocha for efficient

Having an issue here: I need to test a method that involves uploading data to an AWS S3 bucket. However, I don't want the hassle of actually uploading data each time I run my tests or dealing with credentials in the environment settings. That's w ...

Is the 'case' in a switch statement not treated as a typeguard by Typescript?

Here is a simplified version of the code I am working with: type Todo = { id: string; text: string; }; type Action = | { type: 'DELETE'; payload: string } | { type: 'CREATE'; payload: Todo } function reducer(state: Todo[], ...

Should private members be kept confidential during program execution?

While Typescript's "private" members may not be truly private at runtime, traditional closures maintain the privacy of their members. Is there value in ensuring that private members remain private during runtime? ...

I encountered an issue with my TypeScript function in Angular, as it is unable to process multiple uploaded files

I'm having trouble with my TypeScript function in Angular that is unable to read multiple uploaded files. fileUpload(event: Event) { const self = this; this.imageUploadInp = event.target as HTMLInputElement; this.imageUploadInp.addEventLis ...

What is the process for importing a component at a later time?

I am attempting to import components with a delay in a seamless manner. My goal is to import the components discreetly so that they load smoothly in the background while viewing the homepage. I experimented with lazy loading, but found that it caused dela ...

What is the best way to extract value from subscribing?

I attempted to accomplish this task, however, I am encountering issues. Any assistance you can provide would be greatly appreciated! Thank you! export class OuterClass { let isUrlValid = (url:string) => { let validity:boolean ...

Issues with the functionality of Angular Firebase Authentication Service

I am currently working on setting up an authentication service in Angular that will integrate with Google Firebase for a Login form. However, I have encountered an issue where including the service in the constructor of my LoginComponent prevents me from a ...

Typescript: Subscribed information mysteriously disappeared

[ Voting to avoid putting everything inside ngOnit because I need to reuse the API response and model array in multiple functions. Need a way to reuse without cluttering up ngOnInit. I could simply call subscribe repeatedly in each function to solve the p ...

Steps for showing a component (popup modal) just one time with React hooks

Is there a way to implement a popup modal that only appears once using hooks and localStorage? The modal should already appear upon page load. const [showModal, setShowModal] = useState<boolean>(true) return( <ModalIsContractor ...

Guide to inserting an Angular routerLink within a cell in ag-Grid

When attempting to display a link on a basic HTML page, the code looks like this: <a [routerLink]="['/leverance/detail', 13]">A new link</a> However, when trying to render it within an ag-Grid, the approach is as follows: src\ ...

Create a reusable React component in Typescript that can handle and display different types of data within the same

I have a requirement to display four different charts with varying data types. For instance, interface dataA{ name: string, amount: number } interface dataB{ title: string, amount: number } interface dataC{ author: string, amount: ...

loop through an intricate JSON schema using Angular 5

I've been trying to figure out how to iterate a complex JSON in Angular 5. I came across the pipe concept, but it doesn't seem to work with JSON data like the one below. I'm trying to create an expandable table using this type of data, but I ...

The function of type 'PromiseConstructor' is not executable. Should 'new' be added? React TypeScript

.then causing issues in TypeScript. interface Props { type: string; user: object; setUserAuth: Promise<any>; } const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { e.preventDefault(); if (type === "signup" ...