Skip to content

Commit 26e0c41

Browse files
dave11mjdond2clouds
authored andcommitted
docs(@angular/cli): Updates global library instructions (angular#6339)
1 parent b27e098 commit 26e0c41

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

docs/documentation/stories/global-scripts.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,25 @@ global library, and one imported as a module.
3232
This is especially bad for libraries with plugins, like JQuery, because each copy will have
3333
different plugins.
3434

35-
Instead, download typings for your library (`npm install @types/jquery`) which will give you
36-
access to the global variables exposed by that library.
35+
Instead, download typings for your library (`npm install @types/jquery`) and follow
36+
the [3rd Party Library Installation](https://github.com/angular/angular-cli/wiki/stories-third-party-lib) steps,
37+
this will give you access to the global variables exposed by that library.
3738

3839
If the global library you need to use does not have global typings, you can also declare them
3940
manually in `src/typings.d.ts` as `any`:
4041

4142
```
4243
declare var libraryName: any;
43-
```
44+
```
45+
46+
When working with scripts that extend other libraries, for instance with JQuery plugins
47+
(e.g, `$('.test').myPlugin();`), since the installed `@types/jquery` may not include `myPlugin`,
48+
you would need to add an interface like the one below in `src/typings.d.ts`.
49+
50+
```
51+
interface JQuery {
52+
myPlugin(options?: any): any;
53+
}
54+
```
55+
56+
Otherwise you may see `[TS][Error] Property 'myPlugin' does not exist on type 'JQuery'.` in your IDE.

0 commit comments

Comments
 (0)