question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem using the marker function with angular cli

See original GitHub issue

Hello, Would you please help me with this error? It happens when I mark a string for extraction. Thanks a lot. /home/bbv/BBV/Client/node_modules/@biesbjerg/ngx-translate-extract/dist/cli/cli.d.ts (1,1): Cannot find type definition file for 'yargs'.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

26reactions
bedag-moocommented, Jan 17, 2018

We just ran into this as well. The cause was that our IDE generated the import

import {_} from "@biesbjerg/ngx-translate-extract";

rather than

import {_} from "@biesbjerg/ngx-translate-extract/dist/utils/utils";

As a consequence, webpack pulled the entire code of ngx-translate-extract into the bundle (no clue why tree shaking didn’t work), and failed upon analysing some transitive dependencies. The resulting stack trace was not pretty, and left the developer mystified.

Of course, it is entirely unnecessary to load the entire extraction tool at runtime if we just want this single function … would it be possible to exclude the marker function from dist/index.js so IDEs only suggest the harmless deep import?

18reactions
giathinh910commented, Aug 3, 2017

My solution is instead of using the built-in marker function, I create a very simple function with the same name “_” like this:

export function _(str: string) {
  return str;
}

then just use:

translationKeys = {
    usernameRequired: _('Username is required!'),
    passwordRequired: _('Password is required!'),
    newPasswordRequired: _('New password is required!'),
    confirmedNewPasswordNotMatched: _('Confirmed password is not matched!')
};

then run the extractor with marker option as the doc said, the extractor still fine your texts while the JIT can work properly. Good luck.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to call a method when a feature/marker is selected in ...
I am having a map with multiple ol/Feature markers. When clicking on a marker some code should be executed. The problem is that...
Read more >
Markers | Maps JavaScript API - Google Developers
You may add the marker later by calling the marker's setMap() method. The following example adds a simple marker to a map at...
Read more >
Dependency injection in action - Angular
When a class requires a dependency, that dependency is added to the constructor as a parameter. When Angular needs to instantiate the class,...
Read more >
Getting Started With Angular Using the Angular CLI
In this tutorial, you created an Angular project using the Angular CLI. You excecuted and ran the project in the browser, and updated...
Read more >
Angular Hello World: Creating Your First Angular Application
The root component looks very pristine and neat, with barely any references or dependencies. The only main thing in this file is the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found