diff --git a/addon/types.ts b/addon/types.ts index 7288baa7..95376b37 100644 --- a/addon/types.ts +++ b/addon/types.ts @@ -1,4 +1,4 @@ -import Mix from '@ember/polyfills/types'; +import type Mix from '@ember/polyfills/types'; export type Nullable = T | null | undefined; diff --git a/addon/utils/mung-options-for-fetch.ts b/addon/utils/mung-options-for-fetch.ts index 3edd628d..d028d7d5 100644 --- a/addon/utils/mung-options-for-fetch.ts +++ b/addon/utils/mung-options-for-fetch.ts @@ -1,8 +1,8 @@ import { serializeQueryParams } from './serialize-query-params'; import { - Method, - FetchOptions, - AjaxOptions, + type Method, + type FetchOptions, + type AjaxOptions, isPlainObject, } from 'ember-fetch/types'; @@ -18,7 +18,7 @@ export default function mungOptionsForFetch( for (const key in options) { if (Object.prototype.hasOwnProperty.call(options, key)) { - fetchOptions[key] = options[key]; + (fetchOptions as any)[key] = (options as any)[key]; } } diff --git a/package.json b/package.json index b834df87..8705c2e1 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,12 @@ "lint:js:fix": "eslint . --fix", "start": "ember serve", "test": "ember test", - "test:node": "ember ts:precompile && mocha && ember ts:clean", + "test:node": "yarn prepack && mocha && yarn postpack", "test:all": "yarn run test:node && ember try:each", "prepublishOnly": "ember ts:precompile", - "postpublish": "ember ts:clean" + "postpublish": "ember ts:clean", + "prepack": "ember ts:precompile", + "postpack": "ember ts:clean" }, "dependencies": { "abortcontroller-polyfill": "^1.7.3", @@ -42,7 +44,7 @@ "caniuse-api": "^3.0.0", "ember-cli-babel": "^7.26.11", "ember-cli-htmlbars": "^6.2.0", - "ember-cli-typescript": "^4.1.0", + "ember-cli-typescript": "^5.2.1", "ember-cli-version-checker": "^5.1.2", "node-fetch": "^2.6.1", "whatwg-fetch": "^3.6.2" @@ -56,10 +58,11 @@ "@embroider/test-setup": "^2.1.1", "@glimmer/component": "^1.1.2", "@glimmer/tracking": "^1.1.2", - "@types/ember": "^4.0.8", - "@types/ember-data": "^4.4.0", - "@types/qunit": "^2.11.1", - "@types/rsvp": "^4.0.3", + "@tsconfig/ember": "^3.0.2", + "@types/ember": "^4.0.9", + "@types/ember-data": "^4.4.14", + "@types/qunit": "^2.19.8", + "@types/rsvp": "^4.0.7", "@typescript-eslint/eslint-plugin": "^6.9.1", "@typescript-eslint/parser": "^6.9.1", "babel-eslint": "^10.0.2", @@ -104,7 +107,7 @@ "stylelint": "^15.4.0", "stylelint-config-standard": "^32.0.0", "stylelint-prettier": "^3.0.0", - "typescript": "^5.0.0", + "typescript": "^5.2.2", "webpack": "^5.78.0" }, "peerDependencies": { diff --git a/tests/dummy/app/config/environment.d.ts b/tests/dummy/app/config/environment.d.ts index 3252cc3d..a8f92b9f 100644 --- a/tests/dummy/app/config/environment.d.ts +++ b/tests/dummy/app/config/environment.d.ts @@ -1,16 +1,14 @@ -export default config; - /** * Type declarations for - * import config from './config/environment' - * - * For now these need to be managed by the developer - * since different ember addons can materialize new entries. + * import config from 'my-app/config/environment' */ declare const config: { - environment: any; + environment: string; modulePrefix: string; podModulePrefix: string; - locationType: string; + locationType: 'history' | 'hash' | 'none' | 'auto'; rootURL: string; + APP: Record; }; + +export default config; diff --git a/tsconfig.json b/tsconfig.json index f4c56d2b..101b4b46 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,39 +1,39 @@ { + "extends": "@tsconfig/ember/tsconfig.json", "compilerOptions": { - "target": "es2017", - "allowJs": true, - "moduleResolution": "node", - "allowSyntheticDefaultImports": true, - "noImplicitAny": true, - "noImplicitThis": true, - "alwaysStrict": true, - "strictNullChecks": true, - "strictPropertyInitialization": true, - "noFallthroughCasesInSwitch": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noEmitOnError": false, - "noEmit": true, - "strictFunctionTypes": true, - "pretty": true, - "stripInternal": true, - "strict": true, - "inlineSourceMap": true, - "inlineSources": true, + + // The combination of `baseUrl` with `paths` allows Ember's classic package + // layout, which is not resolvable with the Node resolution algorithm, to + // work with TypeScript. "baseUrl": ".", - "module": "es6", "paths": { - "dummy/tests/*": ["tests/*"], - "dummy/*": ["tests/dummy/app/*", "app/*"], - "fetch": ["index.d.ts"], - "ember-fetch": ["addon"], - "ember-fetch/*": ["addon/*"], - "ember-fetch/test-support": ["addon-test-support"], - "ember-fetch/test-support/*": ["addon-test-support/*"], - "@ember/debug": ["types/deprecate.d"], - "*": ["types/*"] - } + "dummy/tests/*": [ + "tests/*" + ], + "dummy/*": [ + "tests/dummy/app/*", + "app/*" + ], + "ember-fetch": [ + "addon" + ], + "ember-fetch/*": [ + "addon/*" + ], + "ember-fetch/test-support": [ + "addon-test-support" + ], + "ember-fetch/test-support/*": [ + "addon-test-support/*" + ], + "*": [ + "types/*" + ] + }, + "typeRoots": [ + "./types", + "./node_modules/@types", + ], }, "include": [ "app/**/*", diff --git a/types/global.d.ts b/types/global.d.ts index 800a01b4..0a373c5c 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -1,6 +1,7 @@ // Types for compiled templates -declare module 'ember-fetch/templates/*' { - import { TemplateFactory } from 'htmlbars-inline-precompile'; +declare module 'ember-fetch/templates/*' { + import { TemplateFactory } from 'ember-cli-htmlbars'; + const tmpl: TemplateFactory; export default tmpl; } diff --git a/yarn.lock b/yarn.lock index fc845bf9..90aee3bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2551,6 +2551,11 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== +"@tsconfig/ember@^3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@tsconfig/ember/-/ember-3.0.2.tgz#d1ee5a734c5fa1b039d35a93055edadf816aa16f" + integrity sha512-Whab2JuEA9r1RLke13tKWO7F95C7l3ivwVhxC37v98vOtFOmDA2BisY/6Fnhclmyydc5vOuVPwN3hi8UTboahw== + "@types/acorn@^4.0.3": version "4.0.5" resolved "https://registry.yarnpkg.com/@types/acorn/-/acorn-4.0.5.tgz#e29fdf884695e77be4e99e67d748f5147255752d" @@ -2619,10 +2624,10 @@ dependencies: "@types/node" "*" -"@types/ember-data@^4.4.0": - version "4.4.13" - resolved "https://registry.yarnpkg.com/@types/ember-data/-/ember-data-4.4.13.tgz#4404e5ca892c1cde3a4813abe6e0959920bc5e6b" - integrity sha512-21+UdZmRODcyxpj0P3SG2Z2HHHIAm+lU/YJ7iGYpYrXyLAjLglIUpQ18NFl6x4HALcnukb5hTmiwVdiIbjq1XQ== +"@types/ember-data@^4.4.14": + version "4.4.14" + resolved "https://registry.yarnpkg.com/@types/ember-data/-/ember-data-4.4.14.tgz#aee6991e64de99dc14fa821310992812d2eb5f9a" + integrity sha512-w2lWrzP0ROdya+0dUqs8DN8l2iPPZUtB+H8+OFhsnqKLO3oxaGK9XtbcCn7qjYh2UEExEbj8M8SgkR6/c3Sagg== dependencies: "@types/ember" "*" "@types/ember__error" "*" @@ -2655,10 +2660,10 @@ "@types/jquery" "*" "@types/rsvp" "*" -"@types/ember@^4.0.8": - version "4.0.8" - resolved "https://registry.yarnpkg.com/@types/ember/-/ember-4.0.8.tgz#f337cc2924479096b455abaaf8d20a699b4a1e72" - integrity sha512-G0mI5i5ZUBKV8ONQGhpwQVPW67cjPI+R4qi5PkSXcAvMXu6UOxlVtuk/heoEUeBRpfp+jynajFhVTnePJ2KLnA== +"@types/ember@^4.0.9": + version "4.0.9" + resolved "https://registry.yarnpkg.com/@types/ember/-/ember-4.0.9.tgz#3f2bccb68ce5bea6ea0efbc40bba6a2182ecefa3" + integrity sha512-Bv+yTAISbXlX2I5f9jdSZXf70Pv13KoNCVQsRw6/L/ayk70CGsHxFgAz8+5sK5yNwxx3taFbjil66kU7wk5zCQ== dependencies: "@types/ember__application" "*" "@types/ember__array" "*" @@ -2972,10 +2977,10 @@ resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.9.tgz#66f7b26288f6799d279edf13da7ccd40d2fa9197" integrity sha512-wYLxw35euwqGvTDx6zfY1vokBFnsK0HNrzc6xNHchxfO2hpuRg74GbkEW7e3sSmPvj0TjCDT1VCa6OtHXnubsg== -"@types/qunit@^2.11.1": - version "2.11.1" - resolved "https://registry.yarnpkg.com/@types/qunit/-/qunit-2.11.1.tgz#3496d430d2bb0fa4761f00a27511f46020c6b410" - integrity sha512-vcM5+9O8LZuu5DYseaV4J7ehkYrhkv+aMIuxnF/OqMYlVEdv+odpCH1/5OVztiqxbCqTpQKWuELkMvG7OPycUQ== +"@types/qunit@^2.19.8": + version "2.19.8" + resolved "https://registry.yarnpkg.com/@types/qunit/-/qunit-2.19.8.tgz#b2bad4bfe339819d3dd7fceb2cb5b33e6a14f695" + integrity sha512-L4JyeRG1CJGSzJKd1b78DX/ll91E8e50IXkkl8KzW6W0IWz6FTHWEYvTEi8QVNHkUqUu6hjTffwV7ffxcoka0g== "@types/range-parser@*": version "1.2.6" @@ -3005,11 +3010,16 @@ "@types/glob" "*" "@types/node" "*" -"@types/rsvp@*", "@types/rsvp@^4.0.3": +"@types/rsvp@*": version "4.0.3" resolved "https://registry.yarnpkg.com/@types/rsvp/-/rsvp-4.0.3.tgz#4a1223158453257bce09d42b9eef7cfa6d257482" integrity sha512-OpRwxbgx16nL/0/7ol0WoLLyLaMXBvtPOHjqLljnzAB/E7Qk1wtjytxgBhOTBMZvuLXnJUqfnjb4W/QclNFvSA== +"@types/rsvp@^4.0.7": + version "4.0.7" + resolved "https://registry.yarnpkg.com/@types/rsvp/-/rsvp-4.0.7.tgz#755b861e1c086059a2b1fb8676e004f6f75b7a5e" + integrity sha512-TOsoofOK1MNrZvsoq9op8Qc8r+pYJ6zwH4YCvDXNcsgjtFgS6IP/uGfLW0JH4zJgXGEC1TxJuKe0EBUPIAIA0A== + "@types/semver@^7.5.0": version "7.5.4" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.4.tgz#0a41252ad431c473158b22f9bfb9a63df7541cff" @@ -3521,6 +3531,13 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: "@types/color-name" "^1.1.1" color-convert "^2.0.1" +ansi-to-html@^0.6.15: + version "0.6.15" + resolved "https://registry.yarnpkg.com/ansi-to-html/-/ansi-to-html-0.6.15.tgz#ac6ad4798a00f6aa045535d7f6a9cb9294eebea7" + integrity sha512-28ijx2aHJGdzbs+O5SNQF65r6rrKYnkuwTYm8lZlChuoJ9P1vVzIpWO20sQTqTPDXYp6NFwk326vApTtLVFXpQ== + dependencies: + entities "^2.0.0" + ansi-to-html@^0.6.6: version "0.6.14" resolved "https://registry.yarnpkg.com/ansi-to-html/-/ansi-to-html-0.6.14.tgz#65fe6d08bba5dd9db33f44a20aec331e0010dad8" @@ -6371,12 +6388,12 @@ ember-cli-typescript@^2.0.2: stagehand "^1.0.0" walk-sync "^1.0.0" -ember-cli-typescript@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ember-cli-typescript/-/ember-cli-typescript-4.1.0.tgz#2ff17be2e6d26b58c88b1764cb73887e7176618b" - integrity sha512-zSuKG8IQuYE3vS+c7V0mHJqwrN/4Wo9Wr50+0NUjnZH3P99ChynczQHu/P7WSifkO6pF6jaxwzf09XzWvG8sVw== +ember-cli-typescript@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/ember-cli-typescript/-/ember-cli-typescript-5.2.1.tgz#553030f1ce3e8958b8e4fc34909acd1218cb35f2" + integrity sha512-qqp5TAIuPHxHiGXJKL+78Euyhy0zSKQMovPh8sJpN/ZBYx0H90pONufHR3anaMcp1snVfx4B+mb9+7ijOik8ZA== dependencies: - ansi-to-html "^0.6.6" + ansi-to-html "^0.6.15" broccoli-stew "^3.0.0" debug "^4.0.0" execa "^4.0.0" @@ -6820,6 +6837,11 @@ entities@^1.1.2: resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56" integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w== +entities@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" + integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== + entities@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4" @@ -13918,7 +13940,7 @@ typescript-memoize@^1.0.1: resolved "https://registry.yarnpkg.com/typescript-memoize/-/typescript-memoize-1.1.1.tgz#02737495d5df6ebf72c07ba0d002e8f4cf5ccfa0" integrity sha512-GQ90TcKpIH4XxYTI2F98yEQYZgjNMOGPpOgdjIBhaLaWji5HPWlRnZ4AeA1hfBxtY7bCGDJsqDDHk/KaHOl5bA== -typescript@^5.0.0: +typescript@^5.2.2: version "5.2.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==