Skip to content

Commit

Permalink
chore(sample): various updates to the AMD TS demo app (#479)
Browse files Browse the repository at this point in the history
* chore(AMD typescript sample): various updates

* chore(sample): update AMD TS readme

* chore(sample): add clarifications to AMD TS readme

* chore(sample): syntax updates to AMD TS readme
  • Loading branch information
andygup authored Jul 31, 2023
1 parent bbff9c2 commit e8a40f3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
29 changes: 25 additions & 4 deletions 4.x/typescript/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# TypeScript

The [arcgis-js-api.d.ts](arcgis-js-api.d.ts) file provides type definitions for ArcGIS Maps SDK for JavaScript.
The [arcgis-js-api.d.ts](arcgis-js-api.d.ts) file provides TypeScript type definitions for the ArcGIS Maps SDK for JavaScript's AMD modules.

A copy of this file is also available at [DefinitelyTyped][1] and may be installed using the command:
`npm install --save @types/arcgis-js-api`
The `.d.ts` declaration file only provides type information and can be downloaded from this repo. A copy of the file is also currently available at [DefinitelyTyped][1] and may be installed using the command:
`npm install --save @types/arcgis-js-api`.

Currently, due to limitations in TypeScript, the APIs [autocasting](https://developers.arcgis.com/javascript/latest/programming-patterns/#autocasting) functionality works best in non-TypeScript applications. No changes are required if you are already using the API without any TypeScript build errors.
If you are looking to locally install the SDK library, which contains the full SDK functionality along with the type definitions, then refer to the SDK's [Introduction to tooling](https://developers.arcgis.com/javascript/latest/tooling-intro/) guide topic.

## Known issues

* Currently, due to limitations in TypeScript, the APIs [autocasting](https://developers.arcgis.com/javascript/latest/programming-patterns/#autocasting) functionality works best in non-TypeScript applications. No changes are required if you are already using the SDK without any TypeScript build errors.

## Requirements

Expand All @@ -16,6 +20,23 @@ Currently, due to limitations in TypeScript, the APIs [autocasting](https://deve
* [TypeScript Editor Support][3]
* Type definitions for many other libraries are available [here][4].

## Licensing
Copyright 2023 Esri

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

A copy of the license is available in the repository's [license.txt](https://github.com/Esri/jsapi-resources/blob/master/license.txt) file.

[1]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/arcgis-js-api
[2]: http://www.typescriptlang.org/
[3]: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Editor-Support
Expand Down
6 changes: 3 additions & 3 deletions 4.x/typescript/demo/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Demo App
# Demo App (AMD)

> TypeScript with the [ArcGIS Maps SDK for JavaScript](https://developers.arcgis.com/javascript/)
A simple application that demonstrates using TypeScript with the [ArcGIS Maps SDK for JavaScript](https://developers.arcgis.com/javascript/) AMD modules. The TypeScript file `main.ts` is converted to JavaScript, and the `import` statements are converted to AMD by the TypeScript compiler. When you run the application, it uses the SDK's AMD modules from the [ArcGIS CDN](https://developers.arcgis.com/javascript/latest/install-and-set-up/#amd-modules-via-arcgis-cdn).

## Usage

1. Clone the repo and `npm install` dependencies
2. `npm run dev` to compile `/app/main.ts` to `main.js` in the same folder and watch for changes
3. launch `index.html` in your browser of choice.
3. Launch `index.html` in your browser of choice.
4 changes: 2 additions & 2 deletions 4.x/typescript/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.23/esri/themes/light/main.css">
<link rel="stylesheet" href="https://js.arcgis.com/4.27/esri/themes/light/main.css">
<script>
var locationPath = location.pathname.replace(/\/[^/]*$/, "");
window.dojoConfig = {
Expand All @@ -25,7 +25,7 @@
]
};
</script>
<script src="https://js.arcgis.com/4.23"></script>
<script src="https://js.arcgis.com/4.27"></script>
</head>
<body>
<div id="viewDiv"></div>
Expand Down
6 changes: 1 addition & 5 deletions 4.x/typescript/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"dev": "tsc -w",
"build": "tsc"
},
"dependencies": {
"arcgis-js-api": "^4.23.0"
},
"devDependencies": {
"@types/arcgis-js-api": "^4.23.0",
"typescript": "^4.6.3"
"typescript": "^5.1.6"
}
}
13 changes: 3 additions & 10 deletions 4.x/typescript/demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@
"module": "amd",
"noImplicitAny": true,
"esModuleInterop": true,
"lib": ["DOM","ES2020"],
"jsx": "react",
"jsxFactory": "tsx",
"target": "es5",
"experimentalDecorators": true,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true,
"lib": ["DOM","ES2020"],
"target": "ES2020",
"moduleResolution": "node"
},
"include": [
"../*.d.ts",
"./app/*"
],
"exclude": [
"node_modules"
]
}

0 comments on commit e8a40f3

Please sign in to comment.