From 45d01f4bfead58a4125ee92065672fed33efd6de Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Wed, 15 Apr 2020 20:25:21 +0200 Subject: [PATCH] Update README --- README.md | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dd54fb0ed9..f899daf250 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,9 @@ See our [Open Collective](https://opencollective.com/openlayers/contribute/spons ## IntelliSense support and type checking for VS Code -The ol package contains a src/ folder with JSDoc annotated sources. TypeScript can get type definitions from these sources with a `jsconfig.json` config file in the project root: +The ol package contains a src/ folder with JSDoc annotated sources. TypeScript can get type definitions from these sources with a [`jsconfig.json`](https://gist.github.com/ahocevar/9a7253cb4712e8bf38d75d8ac898e36c#file-jsconfig-json) (when authoring in JavaScript) or [`tsconfig.json`](https://gist.github.com/ahocevar/ad7b52a2fa0f6c5495193cd695ab3780#file-tsconfig-json) (when authoring in TypeScript) config file in the project root: + +
jsconfig.json ```json { @@ -70,13 +72,39 @@ The ol package contains a src/ folder with JSDoc annotated sources. TypeScript c "include": [ "**/*.js", "node_modules/ol/**/*.js" - ] + ], + "typeAcquisition": { + "exclude": ["ol"] + } } ``` -Project template with this configuration: https://gist.github.com/9a7253cb4712e8bf38d75d8ac898e36c. +
+
tsconfig.json -Note that the above only works when authoring in plain JavaScript. For similar configurations with a `tsconfig.json` in TypeScript projects, your mileage may vary. You may want to use a [third-party types package](https://github.com/hanreev/types-ol) in this case. +```json +{ + "compilerOptions": { + "allowJs": true, + "baseUrl": "./", + "paths": { + "ol": ["node_modules/ol/src"], + "ol/*": ["node_modules/ol/src/*"] + } + }, + "include": [ + "**/*.ts", + "node_modules/ol/**/*" + ], + "typeAcquisition": { + "exclude": ["ol"] + } +} +``` + +
+ +TypeScript users may want to use a [third-party types package](https://github.com/hanreev/types-ol) instead. ## Supported Browsers